microservice-appointments

Mauro Gioberti

Appointments Microservice ๐Ÿš€

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!

Built with .NET and Testing Focus


๐Ÿš€ Whatโ€™s This About?

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.

Why Testing and Automation?


๐Ÿ“‚ How Itโ€™s Organized

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

๐Ÿšฆ Get Started Quickly

  1. Clone this repo:

    git clone https://github.com/maurogioberti/microservice-appointments.git
    cd microservice-appointments
    
  2. Restore dependencies:

    dotnet restore
    
  3. Set up and run the solutions:

Main Solution:

  1. Open Microservice.Appointments.sln in Visual Studio or your preferred IDE.
  2. Set Microservice.Appointments.Api as the startup project.
  3. Ensure Docker is running to support the EventBus (RabbitMQ) and Database (SQL Server) containers.
  4. Run the project to host the API locally (by default on http://localhost:[port]).

IntegrityAssurance Solution:

  1. Open Microservice.Appointments.IntegrityAssurance.sln.
  2. Navigate to the Microservice.Appointments.IntegrationTests project.
  3. Ensure the Microservice.Appointments.Api is running in IntegrityAssurance mode.
  4. Execute the tests and validate the workflows.

๐Ÿณ Docker Containers

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:

  1. EventBus (RabbitMQ): Handles asynchronous messaging for domain events like AppointmentCreatedEvent.
  2. 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! ๐Ÿ˜Ž


๐Ÿงช Testing Is Everything

Consistency is key, and this project follows the Given_When_Then naming convention for tests to ensure maintainability.

Test Naming Pattern:

Given_[Condition]_When_[Action]_Then_[ExpectedOutcome]

๐ŸŽฉ Unit Testing

Unit tests keep things predictable:

๐Ÿ”€ Functional Testing

Functional tests check the big picture:

๐Ÿงฌ Automation Is Your Best Friend

Automation makes life easier. Hereโ€™s what this microservice automates:


๐Ÿ–“ Why Testing and Automation Matter

  1. Saves Time: Automating tests means less debugging and more time for coding cool features. ๐Ÿ˜Ž
  2. Confidence in Changes: Know your updates wonโ€™t break the app. ๐Ÿ˜
  3. Smooth Deployments: Automating checks makes the app stable and easy to scale. ๐Ÿชœ

๐ŸšŒ Event Bus: Messaging Made Simple

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:

๐Ÿ’ก The appointment.notification queue listens for incoming events and automatically updates appointments when it receives a notification.


๐Ÿค– Continuous Integration: Built for Reliability

This project features a lightweight CI pipeline to keep everything stable and running smoothly.

๐Ÿ› ๏ธ Steps in the Pipeline:

  1. ๐Ÿงช Run Unit Tests: Ensures all core logic behaves as expected.
  2. ๐Ÿ”€ 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! ๐Ÿค“


๐Ÿ““ License

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! ๐Ÿš€