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>
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using Svrnty.CQRS.Abstractions.Discovery;
|
|
|
|
namespace Svrnty.CQRS.Tests;
|
|
|
|
public class QueryMetaTests
|
|
{
|
|
[Fact]
|
|
public void Name_StripsQuerySuffix()
|
|
{
|
|
var meta = new QueryMeta(typeof(PersonQuery), typeof(object), typeof(IEnumerable<string>));
|
|
Assert.Equal("Person", meta.Name);
|
|
}
|
|
|
|
[Fact]
|
|
public void Name_UsesQueryNameAttribute_WhenPresent()
|
|
{
|
|
var meta = new QueryMeta(typeof(PersonLookupQuery), typeof(object), typeof(string));
|
|
Assert.Equal("customPersonLookup", meta.Name);
|
|
}
|
|
|
|
[Fact]
|
|
public void LowerCamelCaseName_ConvertsFirstCharToLower()
|
|
{
|
|
var meta = new QueryMeta(typeof(PersonQuery), typeof(object), typeof(IEnumerable<string>));
|
|
Assert.Equal("person", meta.LowerCamelCaseName);
|
|
}
|
|
|
|
[Fact]
|
|
public void Category_DefaultsToBasicQuery()
|
|
{
|
|
var meta = new QueryMeta(typeof(PersonQuery), typeof(object), typeof(IEnumerable<string>));
|
|
Assert.Equal("BasicQuery", meta.Category);
|
|
}
|
|
|
|
[Fact]
|
|
public void QueryType_IsSetCorrectly()
|
|
{
|
|
var meta = new QueryMeta(typeof(PersonQuery), typeof(object), typeof(IEnumerable<string>));
|
|
Assert.Equal(typeof(PersonQuery), meta.QueryType);
|
|
}
|
|
|
|
[Fact]
|
|
public void ServiceType_IsSetCorrectly()
|
|
{
|
|
var serviceType = typeof(object);
|
|
var meta = new QueryMeta(typeof(PersonQuery), serviceType, typeof(IEnumerable<string>));
|
|
Assert.Equal(serviceType, meta.ServiceType);
|
|
}
|
|
|
|
[Fact]
|
|
public void QueryResultType_IsSetCorrectly()
|
|
{
|
|
var resultType = typeof(IEnumerable<string>);
|
|
var meta = new QueryMeta(typeof(PersonQuery), typeof(object), resultType);
|
|
Assert.Equal(resultType, meta.QueryResultType);
|
|
}
|
|
}
|