Skip to content

Commit

Permalink
Add an architecture diagram for Aspire project (#1174)
Browse files Browse the repository at this point in the history
* Add an architecture diagram for Aspire project

* .

* "WireMock.Net : " +

* .
  • Loading branch information
StefH authored Oct 4, 2024
1 parent eb7e6c3 commit 5e04ff1
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 14 deletions.
44 changes: 36 additions & 8 deletions examples-Aspire/AspireApp1.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,48 @@

var builder = DistributedApplication.CreateBuilder(args);

//IResourceBuilder<ProjectResource> apiService = builder.AddProject<Projects.AspireApp1_ApiService>("apiservice");
IResourceBuilder<ProjectResource> apiService = builder.AddProject<Projects.AspireApp1_ApiService>("apiservice");

var mappingsPath = Path.Combine(Directory.GetCurrentDirectory(), "WireMockMappings");

Console.WriteLine($"MappingsPath: {mappingsPath}");
//IResourceBuilder<WireMockServerResource> apiService = builder
// .AddWireMock("apiservice", WireMockServerArguments.DefaultPort)
// .WithMappingsPath(mappingsPath)
// .WithReadStaticMappings()
// .WithApiMappingBuilder(WeatherForecastApiMock.BuildAsync);

var wiremock = builder
.AddWireMock("apiservice", WireMockServerArguments.DefaultPort)
.WithMappingsPath(mappingsPath)
.WithReadStaticMappings()
.WithApiMappingBuilder(WeatherForecastApiMock.BuildAsync);
//var apiServiceUsedForDocs = builder
// .AddWireMock("apiservice1", WireMockServerArguments.DefaultPort)
// .WithApiMappingBuilder(adminApiBuilder =>
// {
// var summaries = new[]
// {
// "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
// };

// adminApiBuilder.Given(b => b
// .WithRequest(request => request
// .UsingGet()
// .WithPath("/weatherforecast2")
// )
// .WithResponse(response => response
// .WithHeaders(h => h.Add("Content-Type", "application/json"))
// .WithBodyAsJson(() => Enumerable.Range(1, 5).Select(index =>
// new WeatherForecast
// (
// DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
// Random.Shared.Next(-20, 55),
// "WireMock.Net : " + summaries[Random.Shared.Next(summaries.Length)]
// ))
// .ToArray())
// )
// );

// return Task.CompletedTask;
// });

builder.AddProject<Projects.AspireApp1_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(wiremock);
.WithReference(apiService);

builder.Build().Run();
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static async Task BuildAsync(AdminApiMappingBuilder builder)
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
"WireMock.Net 2 : " + summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
{
"date": "2024-05-24",
"temperatureC": -17,
"summary": "Balmy"
"summary": "WireMock.Net 1 : Balmy"
},
{
"date": "2024-05-25",
"temperatureC": -13,
"summary": "Mild"
"summary": "WireMock.Net 1 : Mild"
},
{
"date": "2024-05-26",
"temperatureC": 31,
"summary": "Bracing"
"summary": "WireMock.Net 1 : Bracing"
},
{
"date": "2024-05-27",
"temperatureC": 6,
"summary": "Hot"
"summary": "WireMock.Net 1 : Hot"
},
{
"date": "2024-05-28",
"temperatureC": -2,
"summary": "Mild"
"summary": "WireMock.Net 1 : Mild"
}
],
"Headers": {
Expand Down
59 changes: 59 additions & 0 deletions src/WireMock.Net.Aspire/doc/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
overview
```mermaid
classDiagram
class WireMockServerResource {
}
class ContainerResource {
}
class IResourceWithServiceDiscovery {
}
class IResourceWithEndpoints {
}
class WireMockServerArguments {
}
class EndpointReference {
}
class AdminApiMappingBuilder {
}
class IWireMockAdminApi {
}
class MappingModelBuilder {
}
class WireMockServerLifecycleHook {
}
class ResourceLoggerService {
}
class DistributedApplicationModel {
}
class IDistributedApplicationLifecycleHook {
}
WireMockServerResource --> ContainerResource : Inherits
WireMockServerResource --> IResourceWithServiceDiscovery : Implements
WireMockServerResource --> WireMockServerArguments : Uses
WireMockServerResource --> EndpointReference : Returns
WireMockServerArguments --> AdminApiMappingBuilder : Uses
AdminApiMappingBuilder --> MappingModelBuilder : Uses
AdminApiMappingBuilder --> IWireMockAdminApi : Uses
IResourceWithServiceDiscovery --> IResourceWithEndpoints : Inherits
WireMockServerLifecycleHook --> IDistributedApplicationLifecycleHook : Implements
WireMockServerLifecycleHook --> ResourceLoggerService : Uses
WireMockServerLifecycleHook --> DistributedApplicationModel : Uses
WireMockServerLifecycleHook --> WireMockServerResource : Uses
WireMockServerLifecycleHook --> IWireMockAdminApi : Uses
```

0 comments on commit 5e04ff1

Please sign in to comment.