You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Aspire with Dapr support to reference architecture solution
- Add AppHost and ServiceDefaults projects
- Add Aspire.Hosting.Dapr package to AppHost
- Reference Customer and Order from AppHost
- Reference ServiceDefaults project from Customer and Order
- Call builder.AddServiceDefaults() from Program in Customer and Order
- Switch to MongoEventCache in Order
- Add appsettings.Specs.json to Customer and Order
- Add specs profile to AppHost launchSettings.json
- Remove tye.yaml files
- Update ReadMe.md, DevelopmentGuide.md
Copy file name to clipboardExpand all lines: ReadMe.md
+49-26Lines changed: 49 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -3,16 +3,21 @@
3
3
Reference architecture for using **Event Driven .NET** abstractions and libraries for [Domain Driven Design](https://en.wikipedia.org/wiki/Domain-driven_design) (DDD), [Command Query Responsibility Segregation](https://martinfowler.com/bliki/CQRS.html) (CQRS) and [Event Driven Architecture](https://en.wikipedia.org/wiki/Event-driven_architecture) (EDA).
4
4
5
5
## Prerequisites
6
-
-[.NET Core SDK](https://dotnet.microsoft.com/download) (6.0 or greater)
6
+
-[.NET Core SDK](https://dotnet.microsoft.com/download) (8.0 or greater)
> **Note**: As an alternative to Tye, you can run services directly usng the [Dapr CLI](https://docs.dapr.io/getting-started/install-dapr-cli/). This may be useful for troubleshooting Dapr issues after setting `Microsoft.AspNetCore` logging level to `Debug`:
1. Open a terminal at the **reference-architecture** directory and run Tye to launch all services simultaneously.
47
-
```
48
-
tye run
49
-
```
50
-
2. Alternatively, run Tye in debug mode.
51
-
```
52
-
tye run --debug *
53
-
```
54
-
- Set breakpoints in **OrderService**, **CustomerService**.
55
-
- Attach the IDE debugger to **OrderService.dll**, **CustomerService.dll**.
56
-
3. Open the Tye dashboard at http://localhost:8000 to inspect service endpoints and view logs.
57
-
4. Create some customers.
48
+
1. If using an IDE such as Visual Studio or Rider, Using an IDE such as Visual Studio or Rider, run the **http** profile of **ReferenceArchitecture.AppHost**.
49
+
2. Open the Aspire dashboard to inspect service endpoints and view logs.
50
+
3. Create some customers.
58
51
- Open http://localhost:5656/swagger
59
52
- Execute posts using contents of **customers.json**.
60
53
- Copy post response, modify fields, then execute puts.
61
54
- Make sure to copy `etag` value from last response, or you will get a concurrency error.
62
55
- Copy `id` and `etag` values to execute deletes.
63
56
- Execute gets to retrieve customers.
64
57
- View customers database collections using Robo 3T.
65
-
5. Create some orders.
58
+
4. Create some orders.
66
59
- Open http://localhost:5757/swagger
67
60
- Execute posts using contents of **orders.json**.
68
61
- Copy post response, modify fields, then execute puts.
69
62
- Make sure to copy `etag` value from last response, or you will get a concurrency error.
70
63
- Copy `id` and `etag` values to execute deletes.
71
64
- Execute gets to retrieve orders.
72
65
- View orders database collections using Robo 3T.
73
-
6. Update the address of a customer who has order.
66
+
5. Update the address of a customer who has order.
74
67
- Note the address is also updated for the customer's orders.
75
68
- Observe log messages in terminal when integration events are published and handled.
76
69
77
-
## Tests
70
+
## Running Services with the Dapr CLI
71
+
72
+
1. Start the Customer Service using the Dapr CLI from a terminal at the project root.
73
+
74
+
```
75
+
dapr run --app-id customer-service --app-port 5656 --resources-path ../dapr/components -- dotnet run
76
+
```
77
+
78
+
2. Start the Order Service using the Dapr CLI from a terminal at the project root.
79
+
80
+
```
81
+
dapr run --app-id order-service --app-port 5757 --resources-path ../dapr/components -- dotnet run
82
+
```
83
+
84
+
3. Open the Dapr Dashboard at http://localhost:8080
85
+
86
+
87
+
```
88
+
dapr dashboard
89
+
```
90
+
91
+
4. Execute steps 3-5 above to use services and pub-sub features.
92
+
93
+
## Running Tests
78
94
79
95
### Unit Tests
80
96
81
97
In the **test** folder you'll find unit tests for both **CustomerService** and **OrderService** projects.
82
98
- [xUnit](https://xunit.net/) is used as the unit testing framework.
83
99
- [Moq](https://github.com/moq/moq4) is used as the mocking framework.
84
100
85
-
> **Note**: Because database API's are notoriously [difficult to mock](https://jimmybogard.com/avoid-in-memory-databases-for-tests/), **repositories** are deliberately *excluded* from unit testing. Instead, repositories attain code coverage with **integration / acceptance tests**.
101
+
> **Note**: Because database API's are notoriously [difficult to mock](https://jimmybogard.com/avoid-in-memory-databases-for-tests/), **repositories** are deliberately *excluded* from unit testing. Instead, repositories attain code coverage with **acceptance/integration tests**.
86
102
87
-
### Integration / Acceptance Tests
103
+
1. Run unit **CustomerService.Tests** and **OrderService.Tests** from the Test explorer in your IDE.
104
+
2. Alternatively, open a terminal at **CustomerService.Tests** and **OrderService.Tests**, then run `dotnet test`
88
105
89
-
In the **tests** folder you'll find an **EventDriven.ReferenceArchitecture.Specs** project with automated integration / acceptance tests.
106
+
### Acceptance (Integration) Tests
107
+
108
+
In the **tests** folder you'll find an **EventDriven.ReferenceArchitecture.Specs** project with automated acceptance / integration tests.
90
109
- [SpecFlow](https://specflow.org/) is used as the acceptance testing framework.
91
110
- Feature files use [Gherkin](https://specflow.org/learn/gherkin/) syntax to enable [Behavior Driven Development](https://en.wikipedia.org/wiki/Behavior-driven_development) with scenarios that match **acceptance criteria** in user stories.
92
111
112
+
1. Using an IDE such as Visual Studio or Rider, run the **specs** profile of **ReferenceArchitecture.AppHost**.
113
+
2. Run **EventDriven.ReferenceArchitecture.Specs** from the Test explorer of your IDE.
114
+
3. Alternatively, open a terminal at **EventDriven.ReferenceArchitecture.Specs**, then run `dotnet test`
115
+
93
116
## Development Guide
94
117
95
118
For step-by-step instructions on how to build microservices with [Event Driven .NET](https://github.com/event-driven-dotnet/Home) using this reference architecture, please see the **Event Driven .NET** [Development Guide](DevelopmentGuide.md).
0 commit comments