This project is a comprehensive assignment featuring robust unit, integration, and end-to-end tests to showcase best testing practices and methodologies.
- Develop an API exposing a simplified smart charging domain.
- Manage Groups, Charge Stations, and Connectors with full CRUD operations.
- Ensure all operations adhere to strict functional requirements.
- Extensive testing coverage for all functionalities.
- Create, update, and remove Group/Charge Station/Connector.
- Removing a Group also removes all associated Charge Stations.
- Add/remove only one Charge Station to/from a Group per call.
- Charge Stations can only belong to one Group at a time.
- Connectors can only exist within a Charge Station.
- Update the Max current in Amps of existing Connectors.
- Group Capacity in Amps must be greater than or equal to the sum of the Max current in Amps of all Connectors in the Group.
- Reject operations/requests not meeting the above requirements.
First, the database needs to be created and migrations to be applied.
Before creating the database and applying migrations, ensure that you have the necessary SQL Server instance accessible. If your SQL Server instance is hosted on the cloud or running within a Docker container, simply modify the connection string in the appsettings.json file to point to your SQL Server instance.
The default one is set on locally installed SQL Server instance
It can be done following below steps:
// appsettings.json file
"AppDbConnStr": "Data Source=localhost;Initial Catalog=CharginAssignment;Trusted_Connection=True;TrustServerCertificate=True;"
This can be done in two ways:
-
Visual Studio: Open Package Manager Console of Visual Studio. Set Default project on
*.Infratructure
and Startup project on*.API
one. Then run the update database command:Update-Database
-
.NET CLI: In Windows Explorer, go to the
{project-path}/src/CharginAssignment.WithTests.Infrastructure
path, then open a command line there and run this command:dotnet ef database update -s "..\CharginAssignment.WithTests.Web.API"
Run the project by dotnet run
or via Visual Studio, and the Swagger page will pop up as a sign that the application has started.
Clean Architecture has been implemented with the following projects:
- API (WebAPI project)
- Application (Class Library)
- Infrastructure (Class Library)
- Domain (Class Library)
Also, the CQRS pattern is followed by using the MediatR
library.
Use .NET 8, EF Core (ORM), SQL Server as the data store, AutoMapper for mappings, Unit/Integration
tests using xUnit/Moq/FluentAssertions/Bogus
, In Memory DB for Integration Tests, Logging with Serilog configured the log file as target sink.