A .NET Core Web API demonstrating simple CRUD operations for Alza. Functionality is implemented using the CQRS pattern with MediatR.
- .NET 8.0
- Docker
- Start the database:
docker-compose up postgres
- Run migrations:
dotnet ef database update -p Alza.Infrastructure -s Alza.Api
- Run the application:
dotnet run --project Alza.Api
You can now access the API manually at http://localhost:5258/swagger/index.html
through Swagger UI.
You can change application URL in lauchSettings.json
. Note that I have not tested IIS or HTTPS.
- Default database configuration
- This database is used for development purposes only and does not persist data
Switch to postgres database:
- Setting
"UseInMemoryDatabase": false
inappsettings.json
orappsettings.Development.json
- The connection string can be changed in
appsettings.json
orappsettings.Development.json
- By default, data seeding is turned on
- Only seeds data if the database is empty
- Setting
"TryGenerateBogusData": false
inappsettings.json
orappsettings.Development.json
turns it off
Run tests:
dotnet test
Tests cover:
- API endpoints
- CQRS handlers
- Repository operations
Tests are implemented using xUnit and Moq. Tests cover usually only the happy path, but some tests also cover error cases.
There is also a docker image available for the API. It can be launched with:
docker-compose up alza-api
The containerized API can be accessed at http://localhost:8080/swagger/index.html
through Swagger UI.
The port can be changed in docker-compose.yml
.