Topic
Testing & Refactoring
Techniques for changing C# safely, writing tests that catch real regressions, and measuring maintainability instead of debating it.
Practice this topic: C# refactoring exercises →
Try Flatten the Null Checks → Free, no account needed
Latest articles
RSS feed →13 articles
No articles match. Try fewer words or a different term. Search all articles
Guard clauses in C#: flatten nesting, keep the behavior
Guard clauses turn nested conditionals into a flat list of early exits. One refactor took nesting from 5 to 1 while cyclomatic complexity stayed at 6.
Read article →Boundary value analysis: choosing tests at the edges
Boundary value analysis picks test inputs on both sides of every partition edge. See it catch off-by-one mutants that full branch coverage lets through.
Read article →TimeProvider testing in C#: stop waiting for the clock
Make TimeProvider testing in C# deterministic. Check expiry and delays with FakeTimeProvider, distinguish elapsed time, and avoid asynchronous clock races.
Read article →Property-based testing in C#: invariants that find bugs
Use property-based testing in C# to check invariants with FsCheck, generate valid inputs, shrink failing cases, and turn discoveries into regression tests.
Read article →Mocks vs stubs vs fakes: choosing a test double in C#
Mocks vs stubs vs fakes in C#: what each test double can detect, why interaction-heavy mocks go red on every refactor, and when a hand-written fake wins.
Read article →Integration testing in .NET with Testcontainers and WebApplicationFactory
Integration testing in .NET with Testcontainers and WebApplicationFactory runs your API against real PostgreSQL, so constraints and query counts get tested.
Read article →Mutation Testing in C# with Stryker.NET
Mutation testing in C# plants controlled bugs and asks whether your tests notice. Learn Stryker.NET, triage survivors, and set useful CI gates.
Read article →Code smells: a working catalog of six, with C# examples
Code smells are symptoms, not verdicts. Six worth knowing, with C# examples: the tell for each, why it hurts, and the refactoring move that clears it.
Read article →Cyclomatic complexity: what the number actually tells you
Cyclomatic complexity counts the independent paths through a method. How to compute it by eye, what a score of 10 predicts, and how to reduce it for real.
Read article →Unit testing best practices: test behavior, not implementation
Unit testing best practices in C# with xUnit examples. Assert behavior instead of implementation, and remove what makes tests flaky so red means broken.
Read article →Primitive obsession: the bug the compiler was begging to catch
When everything is a string, a decimal, or a Guid, the type system cannot tell arguments apart. Value objects in modern C#, the bugs they delete, their limits.
Read article →Refactoring legacy C# code safely: a test-first playbook
How to refactor legacy C# without breaking it: write characterization tests first, then take small behavior-preserving steps like extract method and seams.
Read article →Clean code is a vibe until you measure it
Four code quality metrics you can automate in C#: cyclomatic complexity, nesting depth, method length, and duplication, with thresholds and a passing refactor.
Read article →