Unitests utilities for PGMS.CQSLight - Fake impementations of Transaction, UnitOfWork - In Memory EntityRepository
$ dotnet add package PGMS.CQSLight.UnitTestUtilitiesPGMS.CQSLight is a small, open-source library that provides a simple and easy-to-use interface for implementing the Command Query Separation (CQS) pattern in .NET Core applications. The library is designed to be lightweight, flexible, and easy to test.
The CQS pattern is a software design pattern that separates the responsibility of executing a command from the responsibility of querying data. The pattern is based on the idea that a method or function should either change the state of the system or retrieve data, but not both.
In PGMS.CQSLight, commands and queries are separated into different interfaces, and each command and query is handled by a specific handler. The library also provides a simple interface for dispatching commands and handling queries.
PGMS.CQSLight is built with SOLID principles, which makes the code maintainable, scalable, and testable. It's an easy to use library, and it's a good fit for small and medium-sized projects that need to implement the CQS pattern.
Unit test utilities for PGMS.CQSLight - Fake implementations and in-memory repositories
This package provides essential testing utilities to facilitate unit testing of applications built with PGMS.CQSLight.
Fake Implementations:
FakeBus: In-memory bus that tracks published events and commands for verificationFakeQueryProcessor: Stub query processor for testingFakeDataService: Simple ID generator for testingFakeUnitOfWork / FakeTransaction: No-op implementations for testing without databaseIn-Memory Repository: InMemoryEntityRepository - fully functional in-memory implementation of IEntityRepository
In-Memory Reporting Repository: InMemoryReportingRepository<TContext> - enhanced version with navigation property resolution
These utilities enable fast, isolated unit tests without the need for a database connection. Use FakeBus to verify that commands publish the expected events, and to test query handlers and event handlers with in-memory data.
InMemoryEntityRepositoryHave a look at our sample app based on PGMS.CQSLight: GitHub Repository
Version 5.X => DotNet 10.0
Version 4.X => DotNet 8.0
Version 3.X => DotNet 6.0
Version 2.X => DotNet 5.0