Add tests/Svrnty.CQRS.Tests with 61 tests covering: - CommandMeta and QueryMeta metadata creation and naming conventions - CommandDiscovery and QueryDiscovery lookup, existence, and enumeration - DI service registration for commands (with/without result) and queries - Full pipeline integration (register -> discover -> resolve) - CqrsBuilder fluent API configuration - CqrsConfiguration generic storage and mapping callbacks - Handler execution via DI-resolved instances Co-Authored-By: Svrnty Inc. <eng@svrnty.com>
65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
using Svrnty.CQRS.Abstractions.Discovery;
|
|
|
|
namespace Svrnty.CQRS.Tests;
|
|
|
|
public class CommandMetaTests
|
|
{
|
|
[Fact]
|
|
public void Name_StripsCommandSuffix()
|
|
{
|
|
var meta = new CommandMeta(typeof(CreatePersonCommand), typeof(object));
|
|
Assert.Equal("CreatePerson", meta.Name);
|
|
}
|
|
|
|
[Fact]
|
|
public void Name_UsesCommandNameAttribute_WhenPresent()
|
|
{
|
|
var meta = new CommandMeta(typeof(CreateWidgetCommand), typeof(object));
|
|
Assert.Equal("customCreate", meta.Name);
|
|
}
|
|
|
|
[Fact]
|
|
public void LowerCamelCaseName_ConvertsFirstCharToLower()
|
|
{
|
|
var meta = new CommandMeta(typeof(CreatePersonCommand), typeof(object));
|
|
Assert.Equal("createPerson", meta.LowerCamelCaseName);
|
|
}
|
|
|
|
[Fact]
|
|
public void LowerCamelCaseName_PreservesAlreadyLowerCase()
|
|
{
|
|
var meta = new CommandMeta(typeof(CreateWidgetCommand), typeof(object));
|
|
// customCreate -> already lower first char
|
|
Assert.Equal("customCreate", meta.LowerCamelCaseName);
|
|
}
|
|
|
|
[Fact]
|
|
public void CommandType_IsSetCorrectly()
|
|
{
|
|
var meta = new CommandMeta(typeof(CreatePersonCommand), typeof(object));
|
|
Assert.Equal(typeof(CreatePersonCommand), meta.CommandType);
|
|
}
|
|
|
|
[Fact]
|
|
public void ServiceType_IsSetCorrectly()
|
|
{
|
|
var serviceType = typeof(object);
|
|
var meta = new CommandMeta(typeof(CreatePersonCommand), serviceType);
|
|
Assert.Equal(serviceType, meta.ServiceType);
|
|
}
|
|
|
|
[Fact]
|
|
public void CommandResultType_IsSetCorrectly_WithThreeArgConstructor()
|
|
{
|
|
var meta = new CommandMeta(typeof(CreatePersonCommand), typeof(object), typeof(CreatePersonResult));
|
|
Assert.Equal(typeof(CreatePersonResult), meta.CommandResultType);
|
|
}
|
|
|
|
[Fact]
|
|
public void CommandResultType_IsNull_WithTwoArgConstructor()
|
|
{
|
|
var meta = new CommandMeta(typeof(DeletePersonCommand), typeof(object));
|
|
Assert.Null(meta.CommandResultType);
|
|
}
|
|
}
|