There are four projects.
- Basket.Api is the web api project containing the basket controller, swagger spec and the Dockerfile used to deploy the app
- Basket.Domain contains all the domain logic required to complete the task. The database is just the InMemoryDatabase.
- Basket.Client is all the logic to complete task 2.
- Basket.Tests contains all the tests for the domain and the client.
I have assumed that the basket will be tied to a cusomter. I have also assumed that the customer will be contained in another service. A basket contains items. Basket items are an instance of a product. The product is what is being sold, basket item is that product in the basket. Again, I have assumed that the products come from an external service.
There are two ways to build basket api
- Open Basket.sln in visual studio and then press ctrl-B
- Open console are the root of the project and run
dotnet build
If you are using visual studio, press f5 and it will start up.
From the console run dotnet run .\src\Basket.Api\Basket.Api.csproj
Both should start the web app on the url http://localhost:55603 (however this could change). To check that it is running correctly navigate to the healthcheck url http://localhost:55603/healthcheck
Within visual studio, right-click the test project and select run unit tests or dotnet test
In the console run dotnet test .\src\Basket.Tests\Basket.Tests.csproj
I find swagger a good way to document and test the api. I have setup swagger and the swagger UI can be found at http://localhost:55603/swagger
I have setup appveyor to run on every commit. This makes sure the solution builds, the tests pass and produces the app in a container. The code for appveyor is in the ci folder. The current status can be found at https://ci.appveyor.com/project/JamesLappin/basketapi
Once the tests have passed, a docker image is created and uploaded to dockerhub. This can be found here.
To run the app from docker run docker run -it -p 55603:80 jameslappin/basketapi
To run the app from docker run docker run -it -p 55603:80 jameslappin/basketapi