A fun-to-use C# microservice built with .NET 8.
Itβs all about testing, automation, and making developersβ lives easier.
β Leave a star if you like it!
π° Found a bug? Report it here!
The Appointments Microservice is a testing playground disguised as a backend app. Itβs built to show off Unit Testing, Functional Testing, and Automation. Sure, it uses Clean Architecture, but the star of the show is making sure everything is fully tested and automated for reliability.
- Unit Testing: Keeps your core logic solid, even when the code changes.
- Functional Testing: Makes sure the app behaves how it should in the real world.
- Automation: π This is where the fun begins! Verifies the integrity of the microservice implementation by hitting endpoints or interacting with bus services.
This app keeps things clean, testable, and easy to automate:
/Microservice.Appointments.sln # Main solution
/Microservice.Appointments.IntegrityAssurance.sln # Testing solution
/src
βββ Api # Your API controllers, middlewares
βββ Application # Use cases, DTOs, and services
βββ Domain # Core business logic like entities and events
βββ Infrastructure # Database, repositories, and external integrations
/tests
βββ FunctionalTests # End-to-end tests for APIs
βββ UnitTests # Isolated tests for logic and services
βββ IntegrationTests # Tests that touch the database or external services
-
Clone this repo:
git clone https://github.com/maurogioberti/microservice-appointments.git cd microservice-appointments
-
Restore dependencies:
dotnet restore
-
Set up and run the solutions:
- Open
Microservice.Appointments.sln
in Visual Studio or your preferred IDE. - Set
Microservice.Appointments.Api
as the startup project. - Ensure Docker is running to support the EventBus (RabbitMQ) and Database (SQL Server) containers.
- Run the project to host the API locally (by default on
http://localhost:[port]
).
- Open
Microservice.Appointments.IntegrityAssurance.sln
. - Navigate to the
Microservice.Appointments.IntegrationTests
project. - Ensure the
Microservice.Appointments.Api
is running in IntegrityAssurance mode. - Execute the tests and validate the workflows.
This project uses Docker to simplify the infrastructure setup. Make sure Docker is running, and the app will handle everything for you automatically.
Take a coffee β and relax while the app spins up the containers. Here's what's included:
- EventBus (RabbitMQ): Handles asynchronous messaging for domain events like
AppointmentCreatedEvent
. - Database (SQL Server): Stores appointment data and ensures persistence for the service.
Everything is pre-configured and ready to go. Just hit "Run" and start testing! π
Consistency is key, and this project follows the Given_When_Then naming convention for tests to ensure maintainability.
Given_[Condition]_When_[Action]_Then_[ExpectedOutcome]
- Example:
Given_Valid_Parameters_When_ExecuteAsync_Called_Then_Returns_Expected_Result
.
Unit tests keep things predictable:
- Test the logic in your services, entities, domains, and use cases.
Functional tests check the big picture:
- Validate that API endpoints respond the way theyβre supposed to.
- Mock those infrastructure dependencies so tests donβt need a database.
Automation makes life easier. Hereβs what this microservice automates:
- API Testing: Every endpoint gets tested, so you donβt miss a thing.
- Saves Time: Automating tests means less debugging and more time for coding cool features. π
- Confidence in Changes: Know your updates wonβt break the app. π
- Smooth Deployments: Automating checks makes the app stable and easy to scale. πͺ
This microservice uses RabbitMQ π to handle domain events asynchronously.
Where to manage it?
π Go to RabbitMQ Management UI and log in to see everything in action.
Queues youβll find:
appointment.created
π’: Triggered when a new appointment is created.appointment.changed
π: Handles updates to appointments.appointment.deleted
β: Removes appointment data from the system.appointment.notification
π©: Processes notifications and updates relevant data.
π‘ The appointment.notification
queue listens for incoming events and automatically updates appointments when it receives a notification.
This project features a lightweight CI pipeline to keep everything stable and running smoothly.
- π§ͺ Run Unit Tests: Ensures all core logic behaves as expected.
- π Run Functional Tests: Validates that endpoints and workflows are working correctly.
π‘ With these automated steps, you can push with confidence knowing the app wonβt break! π€
This project is under the MIT License, so feel free to use it, share it, or break itβjust donβt forget to give credit!
If you're a dev π¨βπ» and you've never done something like this... π€ What are you waiting for? π₯ Improve your quality and get excited to dive in! π