Package Description
License
—
Deps
8
Install Size
—
Vulns
✓ 0
Published
May 13, 2024
$ dotnet add package Codeo.CQRS.TestabilityThis is a library to make testing code using Codeo.CQRS a little more convenient, specifically:
queryExecutor.WithMocked<TQuery, TResult>(...)commandExecutor.WithMocked<TCommand, TResult>(...)Suggested use is as follows:
var queryExecurtor = Substitute.For<IQueryExecutor>()
.WithMocked<SomeQuery, SomeResult>(
// see the tests for examples
).WithMocked<AnotherQUery, AnotherResult>(
...
);
var commandExecutor = Substitute.For<ICommandExecutor>()
.WithMocked<SomeCommand, SomeResult>(
// see tests for examples
).WithMocked<AnotherCommand, AnotherResult>(
...
);
Commands and queries can have their results mocked in the following ways:
var expected = new SomeResult();
var queryExecutor = Substitute.For<IQueryExecutor>()
.WithMocked<SomeQuery, SomeResult>(expected);
var expected = new SomeResult();
var queryExecutor = Substitute.For<IQueryExecutor>()
.WithMocked<SomeQuery, SomeResult>(
q => q.SomeParameter == 1,
expected
);
var expected = new SomeResult();
var queryExecutor = Substitute.For<IQueryExecutor>()
.WithMocked<SomeQuery, SomeResult>(
q => q.SomeParameter == 1,
q =>
{
// ... perform some other logic
return expected;
}
);