Page 2 of 3
Imposter: Fast Source-Generated Mocks
Yesterday we covered Moq — the most popular mocking library in .NET. Today we're looking at Imposter, a newer library that takes a different approach: source generation.
Instead of creating mock objec...
Mocking with Moq in C#
Over the past couple of days we've covered unit testing with xUnit and Test-Driven Development. By now you're writing tests and letting them drive your design. But there's a problem that keeps coming ...
Test-Driven Development in C#
If you read yesterday's post on unit testing with xUnit, you've already got the tools you need to write tests. Today we're going to flip the script — instead of writing code first and tests after, we'...
Unit Testing in C# with xUnit
Throughout this design patterns series, testing has come up again and again. The Repository Pattern post showed an InMemoryOrderRepository and used it in a quick test example. The Dependency Injection...
Dependency Injection - Loosely Coupled Components
At the end of the Chain of Responsibility post I mentioned that every pattern in this series has depended on one thing: injecting interfaces rather than creating concrete types directly. We've been do...
Chain of Responsibility - Handling Requests
At the end of the Decorator Pattern post I mentioned that Chain of Responsibility passes a request through a sequence of handlers, each deciding whether to handle it, modify it, or pass it on. If you'...
Decorator Pattern - Behavior Without Modification
At the end of the Repository Pattern post I left you with a teaser: you can wrap a repository with a caching decorator, adding caching transparently without touching your business logic or your origin...
Repository Pattern - Abstracting Data Access
We've been working through a design patterns series. We've covered SOLID principles, composition over inheritance, the Strategy Pattern, and most recently the Factory Pattern. Today we're tackling som...
Factory Pattern - Hiding Object Creation
We've been working through a design patterns series covering SOLID principles, the Strategy Pattern, composition over inheritance, and memoisation. Today we're tackling something you hit every time yo...
Memoisation – Caching Expensive Computations
We've been working through patterns that make your code more flexible and maintainable — SOLID principles, the Strategy Pattern, composition over inheritance. Those are all about structure. Today we'r...
Strangler Fig Pattern - Gradually Replacing Legacy Code
We've been working through design patterns that make your code more flexible. We covered composition over inheritance, the Strategy Pattern, and the SOLID principles that underpin them all. But what d...
Strategy Pattern - Swapping Algorithms at Runtime
We've been exploring design patterns that make your code more flexible and maintainable. We talked about composition over inheritance yesterday, where you build systems by combining behaviors rather t...
Composition Over Inheritance - Flexible Systems
Remember when we kicked off this design patterns series? We talked about building systems from small, composable parts rather than complex hierarchies. Today we're diving into one of the most importan...
SOLID Principles: Foundation of Good Design
SOLID Principles: Foundation of Good Design
In the last post, we talked about breaking down complex code into small, composable pieces. We saw how a massive ProcessOrder method could be refactored int...
Design Patterns Series: Composition Over Complexity
Design Patterns Series: Composition Over Complexity
Welcome to the first article in a series about design patterns and principles in C#. Over the coming posts, I'll be exploring practical patterns tha...