Data Layer
$ dotnet add package PGMS.ScenarioTestingPGMS.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.
Scenario testing framework for integration and end-to-end testing
This package provides a structured approach to writing scenario-based integration tests using the Given-When-Then pattern with NUnit.
Scenario Test Framework: BaseScenarioTest base class for organizing tests with Given/When/Then structure
Test Actions:
ScenarioTestCommand<T>: Execute commands in test scenariosScenarioTestQuery<T, TResult>: Execute queries with result validationScenarioTestCommandWithValidationFailure<T>: Test expected validation failuresScenarioTestDataValidation: Validate data state using repositoryScenarioTestDataManipulation: Manipulate test data directlyTest Helpers:
IScenarioTestHelper: Abstraction for test executionScenarioTestHelperInMemoryImplementation<TContext>: In-memory testing with Autofac containerScenarioTestHelperIntegratedImplementation<TContext>: Integration testing against real database or APIAPI Testing: ICqsApiHelper for testing CQS operations through HTTP APIs with RestSharp
Scenario tests provide a clear, readable structure for integration tests:
This approach makes tests self-documenting and easier to maintain, while supporting both in-memory and integrated testing strategies.
Have 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