Skip to content
bitzorcas
EN

Guide

Writing new tests

How to write tests for BitzOrcas — unit test patterns, integration test patterns, and architecture test patterns.

Last updated

Choose the right test project

You’re testing…Project to use
Domain logic / value objectsBitzOrcas.Unit.Tests
Mediator handler / pipeline behaviorBitzOrcas.Application.Tests
Full endpoint with DBBitzOrcas.Integration.Tests
Module boundary / DI ruleBitzOrcas.Architecture.Tests

Unit test pattern

public class NoteTests
{
[Fact]
public void Create_WithValidData_ShouldSucceed()
{
var note = new Note("Title", "Content");
note.Title.ShouldBe("Title");
note.DomainEvents.ShouldHaveSingleItem();
}
}

Integration test pattern

public class NoteEndpointTests : IClassFixture<CustomWebApplicationFactory>
{
private readonly HttpClient _client;
public NoteEndpointTests(CustomWebApplicationFactory factory)
{
_client = factory.CreateClient();
}
[Fact]
public async Task GetNotes_Returns200()
{
var response = await _client.GetAsync("/api/notes");
response.StatusCode.ShouldBe(HttpStatusCode.OK);
}
}

Architecture test pattern

[Fact]
public void Domain_ShouldNotDependOnInfrastructure()
{
var domain = Types.InAssembly(domainAssembly);
var infra = Types.InAssembly(infrastructureAssembly);
var result = domain.ShouldNot()
.HaveDependencyOnAny(infra.Types)
.GetResult();
result.IsSuccessful.ShouldBeTrue();
}