Skip to content

πŸ€– Automation-focused microservice built with Clean Architecture to show how devs can leverage automation. It features πŸ§ͺ unit tests, πŸ§ͺ functional tests, and integrates SQL Server for db and RabbitMQ 🚌 for event-driven messaging.

License

Notifications You must be signed in to change notification settings

maurogioberti/microservice-appointments

Repository files navigation

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?

  • 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.

πŸ“‚ 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]

  • Example: Given_Valid_Parameters_When_ExecuteAsync_Called_Then_Returns_Expected_Result.

🎩 Unit Testing

Unit tests keep things predictable:

  • Test the logic in your services, entities, domains, and use cases.

πŸ”€ Functional Testing

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 Is Your Best Friend

Automation makes life easier. Here’s what this microservice automates:

  • API Testing: Every endpoint gets tested, so you don’t miss a thing.

πŸ–“ 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:

  • 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.


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

About

πŸ€– Automation-focused microservice built with Clean Architecture to show how devs can leverage automation. It features πŸ§ͺ unit tests, πŸ§ͺ functional tests, and integrates SQL Server for db and RabbitMQ 🚌 for event-driven messaging.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published