BitzOrcas.Integration.Tests exercises the full API pipeline — from HTTP request through middleware, Mediator pipeline, and database operations — using WebApplicationFactory.
Setup
Uses WebApplicationFactory<Program> to bootstrap a test server:
public class CustomWebApplicationFactory : WebApplicationFactory<Program>{ protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureServices(services => { // Override with test configuration services.AddBitzOrcasSqlSugar(opt => opt.ConnectionString = TestDatabase); }); }}Test categories
| Category | Description |
|---|---|
| Endpoint tests | HTTP request → response verification |
| Auth tests | JWT/HMAC/API Key scheme validation |
| Tenant tests | Multi-tenant data isolation |
| Pipeline tests | Mediator behavior chain |
| Seed data tests | CSV seeding correctness |
Example: Endpoint test
[Fact]public async Task CreateNote_Returns201(){ var client = _factory.CreateClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _testToken);
var response = await client.PostAsJsonAsync("/api/notes", new { title = "Test", content = "Content" });
response.StatusCode.ShouldBe(HttpStatusCode.Created); var note = await response.Content.ReadFromJsonAsync<NoteDto>(); note.ShouldNotBeNull(); note.Title.ShouldBe("Test");}Running
dotnet test tests/BitzOrcas.Integration.TestsRequires Docker (SQL Server + RabbitMQ) for full integration tests.