Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
6 posts found #xunit
Clean Test Code: F.I.R.S.T., Readable Asserts and Test Data Builders
Software Design PART 10

Clean Test Code: F.I.R.S.T., Readable Asserts and Test Data Builders

A clean test is fast, independent, repeatable, self-validating and timely (F.I.R.S.T.); the legacy OrderService tests break on Saturdays because of DateTime.Now and depending on run order because of the static Db. With TimeProvider and FakeTimeProvider, a test data builder, test names that read like sentences and asserts that state the reason when they fail, we turn the same rules into clean tests.

7 Nov 2026 11 min 5
Liskov Substitution Principle: Behavioral Subtyping and NotSupportedException in .NET
Software Design PART 05

Liskov Substitution Principle: Behavioral Subtyping and NotSupportedException in .NET

LSP requires a subtype to satisfy not just the compiler but the base type's contract: preconditions aren't strengthened, postconditions aren't weakened, invariants and the history constraint are preserved. Three real violations in Bookstore's stock module, the NotSupportedException that T[] and ReadOnlyCollection throw from IList<T>.Add, capability queries with Stream.CanSeek, and verifying the contract against every implementation with an abstract xUnit test class.

7 Nov 2026 15 min 4
Unit Testing in C#: xUnit, Theory/InlineData and Testable Code
Backend PART 14

Unit Testing in C#: xUnit, Theory/InlineData and Testable Code

The hidden dependencies behind a flaky test, an xUnit test project, Fact and Assert, Theory/InlineData/MemberData, taking time from outside with IClock, and pitfalls like decimal InlineData and async void.

7 Nov 2026 8 min 18
Testing with EF Core: SQLite In-Memory and InMemory Provider Pitfalls
Database PART 22

Testing with EF Core: SQLite In-Memory and InMemory Provider Pitfalls

With real test output we see how the InMemory provider silently lets unique indexes, foreign keys and raw SQL slip through, and build realistic tests with SQLite in-memory. We cover the false green of asserting on the same context and the debate about abstracting DbContext, using the EF documentation's guidance.

5 Nov 2026 10 min 24
Integration Testing an ASP.NET Core Web API: End-to-End Tests with WebApplicationFactory
Backend PART 30

Integration Testing an ASP.NET Core Web API: End-to-End Tests with WebApplicationFactory

We spin up an ASP.NET Core Web API in memory with WebApplicationFactory and test it at the HTTP level: public partial class Program, swapping the database for in-memory SQLite, Location and ProblemDetails tests, and test isolation.

4 Nov 2026 9 min 47
Unit Testing an ASP.NET Core Web API: Service and Controller Tests with xUnit and Moq
Backend PART 29

Unit Testing an ASP.NET Core Web API: Service and Controller Tests with xUnit and Moq

Unit testing an ASP.NET Core Web API with xUnit and Moq: the right package versions for net6.0, AAA and naming, Setup and Verify, the Result/Value difference in ActionResult<T> tests, Theory, and a comparison with NSubstitute.

4 Nov 2026 11 min 40
Blog Map