A curated collection of .NET 9+ integration test samples — showcasing best practices for testing common backend scenarios.
-
ASP.NET Core WebAPI
ShowcaseWebApplicationFactory
and HTTP client testing to validate controllers, routes, status codes, and headers. -
SQL Server Integration
Run real DB tests via Docker-based SQL Server, including database migrations. -
RabbitMQ Message Queues
Set up RabbitMQ and perform message-driven assertions. -
Email Assertions
Use Mailpit to mock SMTP servers and validate email sending in tests. -
Planned Additions
- NoSQL database (e.g., MongoDB)
- Blob storage (local or Azure emulator)
.
├── src/ # Source code folder (WebAPI, database, models, message workers...)
│ ├── Common/ # Shared services, utilities, and extensions
│ ├── Contracts/ # Message contracts and DTOs
│ ├── Database/ # Database migrations and context
│ ├── MessageProcessor / # Message processing logic (e.g., RabbitMQ consumers)
│ ├── Models / # Domain models and entities
│ ├── Tests/ # Integration tests for the WebAPI and MessageProcessor
│ ├── WebApi/ # ASP.NET Core WebAPI project
│ └── ... # Future tests: NoSQL, blob storage
└── .github/ # CI workflows (GitHub Actions + Docker support)
-
Start Docker for dependency services:
-
SQL Server:
docker run --name sqlserver ` -p 1433:1433 --hostname sqlserver ` -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=Str0ng!Database?P@ssword0" ` -d mcr.microsoft.com/mssql/server:2022-latest
-
RabbitMQ:
docker run --name rabbitmq ` -p 15672:15672 ` -d masstransit/rabbitmq
-
Mailpit:
docker run --name mailpit ` -p 8025:8025 -p 1025:1025 ` --restart unless-stopped ` -d axllent/mailpit
-
-
Use
dotnet test
to run all tests.
- Use
WebApplicationFactory<TEntryPoint>
for full HTTP request/response flow. - Replace live services in tests via
builder.ConfigureServices(...)
for test isolation. - Follow Arrange → Act → Assert pattern with real I/O and infrastructure.
- Keep unit tests separate from integration tests for speed and clarity.
- Drop the need for using Postman or manual testing by providing comprehensive integration tests.
Feature | Status |
---|---|
SQL Database: SQL Server | 🟢 Done |
Messaging: RabbitMQ | 🟢 Done |
Email assertion (Inbox mock) | 🟢 Done |
NoSQL DB (e.g., MongoDB) | 🟡 Upcoming |
Blob Storage (emulator) | 🟡 Upcoming |
Contributions welcome! Feel free to submit PRs, feature requests or issues.
- Open an issue to discuss your feature or improvement
- Fork the repo
- Create a branch:
feature/nosql-integration
- Add your samples/tests
- Open a PR detailing your additions and run steps
MIT — see LICENSE for details.
Integration tests validate real behavior: complete HTTP pipelines, actual databases, messaging queues, blob storage, and email. This repo provides real-world samples and starter templates so developers can confidently test .NET apps in production-like environments.
Let me know if you'd like code snippets added, badges, or CI examples!