diff --git a/Directory.Build.props b/Directory.Build.props
index b656c05..ccac037 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -7,11 +7,22 @@
Lightweight, easy-to-use C# library designed to simplify the implementation of the Command Query Responsibility Segregation (CQRS) pattern.
JustFixMe
Copyright (c) 2025 JustFixMe
- https://github.com/JustFixMe/Just.Core/
+ https://github.com/JustFixMe/Just.Cqrs/
- c#;CQRS
+ csharp;cqrs;cqrs-pattern;
LICENSE
readme.md
+
+ 1.0.0
+ $(VersionSuffix)
+ $(ReleaseVersion)
+ $(ReleaseVersion)
+ $(ReleaseVersion)
+
+
+
+
+
diff --git a/src/Just.Cqrs.Abstractions/IDispatchBehaviour.cs b/src/Just.Cqrs.Abstractions/IDispatchBehavior.cs
similarity index 80%
rename from src/Just.Cqrs.Abstractions/IDispatchBehaviour.cs
rename to src/Just.Cqrs.Abstractions/IDispatchBehavior.cs
index 99bfb34..b0fd8e6 100644
--- a/src/Just.Cqrs.Abstractions/IDispatchBehaviour.cs
+++ b/src/Just.Cqrs.Abstractions/IDispatchBehavior.cs
@@ -12,7 +12,7 @@ public delegate ValueTask DispatchFurtherDelegate();
///
/// Marker interface for static type checking. Should not be used directly.
///
-public interface IDispatchBehaviour
+public interface IDispatchBehavior
{
Type RequestType { get; }
Type ResponseType { get; }
@@ -23,7 +23,7 @@ public interface IDispatchBehaviour
///
/// Request type
/// Result type of dispatching command/query
-public interface IDispatchBehaviour : IDispatchBehaviour
+public interface IDispatchBehavior : IDispatchBehavior
where TRequest : notnull
{
ValueTask Handle(
@@ -32,7 +32,7 @@ public interface IDispatchBehaviour : IDispatchBehaviour
CancellationToken cancellationToken);
[ExcludeFromCodeCoverage]
- Type IDispatchBehaviour.RequestType => typeof(TRequest);
+ Type IDispatchBehavior.RequestType => typeof(TRequest);
[ExcludeFromCodeCoverage]
- Type IDispatchBehaviour.ResponseType => typeof(TResponse);
+ Type IDispatchBehavior.ResponseType => typeof(TResponse);
}
diff --git a/src/Just.Cqrs/CqrsServicesExtensions.cs b/src/Just.Cqrs/CqrsServicesExtensions.cs
index 78e2d66..1c75caa 100644
--- a/src/Just.Cqrs/CqrsServicesExtensions.cs
+++ b/src/Just.Cqrs/CqrsServicesExtensions.cs
@@ -27,7 +27,7 @@ public static class CqrsServicesExtensions
{
services.TryAdd(new ServiceDescriptor(service, impl, lifetime));
}
- foreach (var (service, impl, lifetime) in options.Behaviours)
+ foreach (var (service, impl, lifetime) in options.Behaviors)
{
services.Add(new ServiceDescriptor(service, impl, lifetime));
}
@@ -75,43 +75,43 @@ public static class CqrsServicesExtensions
return options;
}
- public static CqrsServicesOptions AddOpenBehaviour(this CqrsServicesOptions options, Type behaviour, ServiceLifetime lifetime = ServiceLifetime.Singleton)
+ public static CqrsServicesOptions AddOpenBehavior(this CqrsServicesOptions options, Type Behavior, ServiceLifetime lifetime = ServiceLifetime.Singleton)
{
- var interfaces = behaviour.FindInterfaces(
+ var interfaces = Behavior.FindInterfaces(
static (x, t) => x.IsGenericType && x.GetGenericTypeDefinition() == (Type)t!,
- typeof(IDispatchBehaviour<,>));
+ typeof(IDispatchBehavior<,>));
if (interfaces.Length == 0)
{
- throw new ArgumentException("Supplied type does not implement IDispatchBehaviour<,> interface.", nameof(behaviour));
+ throw new ArgumentException("Supplied type does not implement IDispatchBehavior<,> interface.", nameof(Behavior));
}
- if (!behaviour.ContainsGenericParameters)
+ if (!Behavior.ContainsGenericParameters)
{
- throw new ArgumentException("Supplied type is not sutable for open behaviour.", nameof(behaviour));
+ throw new ArgumentException("Supplied type is not sutable for open Behavior.", nameof(Behavior));
}
- options.Behaviours.Add((typeof(IDispatchBehaviour<,>), behaviour, lifetime));
+ options.Behaviors.Add((typeof(IDispatchBehavior<,>), Behavior, lifetime));
return options;
}
- public static CqrsServicesOptions AddBehaviour(this CqrsServicesOptions options, ServiceLifetime lifetime = ServiceLifetime.Singleton)
- where TBehaviour : notnull, IDispatchBehaviour
+ public static CqrsServicesOptions AddBehavior(this CqrsServicesOptions options, ServiceLifetime lifetime = ServiceLifetime.Singleton)
+ where TBehavior : notnull, IDispatchBehavior
{
- var type = typeof(TBehaviour);
+ var type = typeof(TBehavior);
var interfaces = type.FindInterfaces(
static (x, t) => x.IsGenericType && x.GetGenericTypeDefinition() == (Type)t!,
- typeof(IDispatchBehaviour<,>));
+ typeof(IDispatchBehavior<,>));
if (interfaces.Length == 0)
{
- throw new InvalidOperationException("Supplied type does not implement IDispatchBehaviour<,> interface.");
+ throw new InvalidOperationException("Supplied type does not implement IDispatchBehavior<,> interface.");
}
foreach (var interfaceType in interfaces)
{
- options.Behaviours.Add((
+ options.Behaviors.Add((
interfaceType,
type,
lifetime));
diff --git a/src/Just.Cqrs/CqrsServicesOptions.cs b/src/Just.Cqrs/CqrsServicesOptions.cs
index 9b8392e..19d9c4c 100644
--- a/src/Just.Cqrs/CqrsServicesOptions.cs
+++ b/src/Just.Cqrs/CqrsServicesOptions.cs
@@ -4,7 +4,7 @@ namespace Just.Cqrs;
public sealed class CqrsServicesOptions(IServiceCollection services)
{
- internal readonly List<(Type Service, Type Impl, ServiceLifetime Lifetime)> Behaviours = [];
+ internal readonly List<(Type Service, Type Impl, ServiceLifetime Lifetime)> Behaviors = [];
internal readonly List<(Type Service, Type Impl, ServiceLifetime Lifetime)> CommandHandlers = [];
internal readonly List<(Type Service, Type Impl, ServiceLifetime Lifetime)> QueryHandlers = [];
diff --git a/src/Just.Cqrs/Internal/CommandDispatcherImpl.cs b/src/Just.Cqrs/Internal/CommandDispatcherImpl.cs
index e8258bb..510d996 100644
--- a/src/Just.Cqrs/Internal/CommandDispatcherImpl.cs
+++ b/src/Just.Cqrs/Internal/CommandDispatcherImpl.cs
@@ -34,12 +34,12 @@ internal sealed class CommandDispatcherImpl(
where TCommand : notnull
{
var handler = services.GetRequiredService>();
- var pipeline = services.GetServices>();
+ var pipeline = services.GetServices>();
using var pipelineEnumerator = pipeline.GetEnumerator();
return DispatchDelegateFactory(pipelineEnumerator).Invoke();
- DispatchFurtherDelegate DispatchDelegateFactory(IEnumerator> enumerator) =>
+ DispatchFurtherDelegate DispatchDelegateFactory(IEnumerator> enumerator) =>
enumerator.MoveNext()
? (() => enumerator.Current.Handle(command, DispatchDelegateFactory(enumerator), cancellationToken))
: (() => handler.Handle(command, cancellationToken));
diff --git a/src/Just.Cqrs/Internal/QueryDispatcherImpl.cs b/src/Just.Cqrs/Internal/QueryDispatcherImpl.cs
index 7ba0d09..1d2a889 100644
--- a/src/Just.Cqrs/Internal/QueryDispatcherImpl.cs
+++ b/src/Just.Cqrs/Internal/QueryDispatcherImpl.cs
@@ -34,12 +34,12 @@ internal sealed class QueryDispatcherImpl(
where TQuery : notnull
{
var handler = services.GetRequiredService>();
- var pipeline = services.GetServices>();
+ var pipeline = services.GetServices>();
using var pipelineEnumerator = pipeline.GetEnumerator();
return DispatchDelegateFactory(pipelineEnumerator).Invoke();
- DispatchFurtherDelegate DispatchDelegateFactory(IEnumerator> enumerator) =>
+ DispatchFurtherDelegate DispatchDelegateFactory(IEnumerator> enumerator) =>
enumerator.MoveNext()
? (() => enumerator.Current.Handle(query, DispatchDelegateFactory(enumerator), cancellationToken))
: (() => handler.Handle(query, cancellationToken));
diff --git a/tests/Cqrs.Tests/CommandDispatcherImplTests/Dispatch.cs b/tests/Cqrs.Tests/CommandDispatcherImplTests/Dispatch.cs
index bd0d793..4b1df85 100644
--- a/tests/Cqrs.Tests/CommandDispatcherImplTests/Dispatch.cs
+++ b/tests/Cqrs.Tests/CommandDispatcherImplTests/Dispatch.cs
@@ -42,12 +42,12 @@ public class Dispatch
await commandHandler.Received(1).Handle(testCommand, CancellationToken.None);
}
- public class TestOpenBehaviour : IDispatchBehaviour
+ public class TestOpenBehavior : IDispatchBehavior
where TRequest : notnull
{
private readonly Action _callback;
- public TestOpenBehaviour(Action callback)
+ public TestOpenBehavior(Action callback)
{
_callback = callback;
}
@@ -60,7 +60,7 @@ public class Dispatch
}
[Fact]
- public async Task WhenPipelineConfigured_ShouldCallAllBehavioursInOrder()
+ public async Task WhenPipelineConfigured_ShouldCallAllBehaviorsInOrder()
{
// Given
var testCommand = new TestCommand();
@@ -72,15 +72,15 @@ public class Dispatch
.Returns(testCommandResult)
.AndDoes(_ => calls.Add("commandHandler"));
- var firstBehaviour = Substitute.For>();
- firstBehaviour.Handle(testCommand, Arg.Any>(), Arg.Any())
+ var firstBehavior = Substitute.For>();
+ firstBehavior.Handle(testCommand, Arg.Any>(), Arg.Any())
.Returns(args => ((DispatchFurtherDelegate)args[1]).Invoke())
- .AndDoes(_ => calls.Add("firstBehaviour"));
+ .AndDoes(_ => calls.Add("firstBehavior"));
- var secondBehaviour = Substitute.For>();
- secondBehaviour.Handle(testCommand, Arg.Any>(), Arg.Any())
+ var secondBehavior = Substitute.For>();
+ secondBehavior.Handle(testCommand, Arg.Any>(), Arg.Any())
.Returns(args => ((DispatchFurtherDelegate)args[1]).Invoke())
- .AndDoes(_ => calls.Add("secondBehaviour"));
+ .AndDoes(_ => calls.Add("secondBehavior"));
ServiceCollection serviceCollection =
[
@@ -90,22 +90,22 @@ public class Dispatch
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour),
- (IServiceProvider _) => firstBehaviour,
+ typeof(IDispatchBehavior),
+ (IServiceProvider _) => firstBehavior,
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour),
- (IServiceProvider _) => secondBehaviour,
+ typeof(IDispatchBehavior),
+ (IServiceProvider _) => secondBehavior,
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour<,>),
- typeof(TestOpenBehaviour<,>),
+ typeof(IDispatchBehavior<,>),
+ typeof(TestOpenBehavior<,>),
ServiceLifetime.Transient
),
];
- serviceCollection.AddTransient>(_ => (TestCommand _) => calls.Add("thirdBehaviour"));
+ serviceCollection.AddTransient>(_ => (TestCommand _) => calls.Add("thirdBehavior"));
var services = serviceCollection.BuildServiceProvider();
var sut = new CommandDispatcherImpl(services, new ConcurrentMethodsCache());
@@ -115,11 +115,11 @@ public class Dispatch
// Then
result.ShouldBeSameAs(testCommandResult);
- await firstBehaviour.Received(1).Handle(testCommand, Arg.Any>(), Arg.Any());
- await secondBehaviour.Received(1).Handle(testCommand, Arg.Any>(), Arg.Any());
+ await firstBehavior.Received(1).Handle(testCommand, Arg.Any>(), Arg.Any());
+ await secondBehavior.Received(1).Handle(testCommand, Arg.Any>(), Arg.Any());
await commandHandler.Received(1).Handle(testCommand, CancellationToken.None);
- calls.ShouldBe(["firstBehaviour", "secondBehaviour", "thirdBehaviour", "commandHandler"]);
+ calls.ShouldBe(["firstBehavior", "secondBehavior", "thirdBehavior", "commandHandler"]);
}
[Fact]
@@ -136,15 +136,15 @@ public class Dispatch
.Returns(testCommandResult)
.AndDoes(_ => calls.Add("commandHandler"));
- var firstBehaviour = Substitute.For>();
- firstBehaviour.Handle(testCommand, Arg.Any>(), Arg.Any())
+ var firstBehavior = Substitute.For>();
+ firstBehavior.Handle(testCommand, Arg.Any>(), Arg.Any())
.Returns(args => ((DispatchFurtherDelegate)args[1]).Invoke())
- .AndDoes(_ => calls.Add("firstBehaviour"));
+ .AndDoes(_ => calls.Add("firstBehavior"));
- var secondBehaviour = Substitute.For>();
- secondBehaviour.Handle(testCommand, Arg.Any>(), Arg.Any())
+ var secondBehavior = Substitute.For>();
+ secondBehavior.Handle(testCommand, Arg.Any>(), Arg.Any())
.Returns(args => ValueTask.FromResult(testCommandResultAborted))
- .AndDoes(_ => calls.Add("secondBehaviour"));
+ .AndDoes(_ => calls.Add("secondBehavior"));
ServiceCollection serviceCollection =
[
@@ -154,22 +154,22 @@ public class Dispatch
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour),
- (IServiceProvider _) => firstBehaviour,
+ typeof(IDispatchBehavior),
+ (IServiceProvider _) => firstBehavior,
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour),
- (IServiceProvider _) => secondBehaviour,
+ typeof(IDispatchBehavior),
+ (IServiceProvider _) => secondBehavior,
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour<,>),
- typeof(TestOpenBehaviour<,>),
+ typeof(IDispatchBehavior<,>),
+ typeof(TestOpenBehavior<,>),
ServiceLifetime.Transient
),
];
- serviceCollection.AddTransient>(_ => (TestCommand _) => calls.Add("thirdBehaviour"));
+ serviceCollection.AddTransient>(_ => (TestCommand _) => calls.Add("thirdBehavior"));
var services = serviceCollection.BuildServiceProvider();
var sut = new CommandDispatcherImpl(services, new ConcurrentMethodsCache());
@@ -179,10 +179,10 @@ public class Dispatch
// Then
result.ShouldBeSameAs(testCommandResultAborted);
- await firstBehaviour.Received(1).Handle(testCommand, Arg.Any>(), Arg.Any());
- await secondBehaviour.Received(1).Handle(testCommand, Arg.Any>(), Arg.Any());
+ await firstBehavior.Received(1).Handle(testCommand, Arg.Any>(), Arg.Any());
+ await secondBehavior.Received(1).Handle(testCommand, Arg.Any>(), Arg.Any());
await commandHandler.Received(0).Handle(testCommand, CancellationToken.None);
- calls.ShouldBe(["firstBehaviour", "secondBehaviour"]);
+ calls.ShouldBe(["firstBehavior", "secondBehavior"]);
}
}
diff --git a/tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddBehaviour.cs b/tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddBehavior.cs
similarity index 77%
rename from tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddBehaviour.cs
rename to tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddBehavior.cs
index ba6bc88..7e494f1 100644
--- a/tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddBehaviour.cs
+++ b/tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddBehavior.cs
@@ -3,12 +3,12 @@ using Microsoft.Extensions.DependencyInjection;
namespace Cqrs.Tests.CqrsServicesExtensionsTests;
-public class AddBehaviour
+public class AddBehavior
{
public class TestCommand {}
public class TestCommandResult {}
[ExcludeFromCodeCoverage]
- public class NonGenericTestOpenBehaviour : IDispatchBehaviour
+ public class NonGenericTestOpenBehavior : IDispatchBehavior
{
public ValueTask Handle(TestCommand request, DispatchFurtherDelegate next, CancellationToken cancellationToken)
{
@@ -20,27 +20,27 @@ public class AddBehaviour
[InlineData(ServiceLifetime.Transient)]
[InlineData(ServiceLifetime.Scoped)]
[InlineData(ServiceLifetime.Singleton)]
- public void WhenCalled_ShouldRegisterDispatchBehaviour(ServiceLifetime lifetime)
+ public void WhenCalled_ShouldRegisterDispatchBehavior(ServiceLifetime lifetime)
{
// Given
ServiceCollection services = new();
// When
services.AddCqrs(opt => opt
- .AddBehaviour(lifetime));
+ .AddBehavior(lifetime));
// Then
services.ShouldContain(
elementPredicate: descriptor =>
- descriptor.ServiceType == typeof(IDispatchBehaviour)
- && descriptor.ImplementationType == typeof(NonGenericTestOpenBehaviour)
+ descriptor.ServiceType == typeof(IDispatchBehavior)
+ && descriptor.ImplementationType == typeof(NonGenericTestOpenBehavior)
&& descriptor.Lifetime == lifetime,
expectedCount: 1
);
}
[ExcludeFromCodeCoverage]
- public class InvalidTestBehaviour : IDispatchBehaviour
+ public class InvalidTestBehavior : IDispatchBehavior
{
public Type RequestType => throw new NotImplementedException();
@@ -57,7 +57,7 @@ public class AddBehaviour
// Then
Should.Throw(() => services.AddCqrs(opt => opt
- .AddBehaviour())
+ .AddBehavior())
);
}
}
diff --git a/tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddOpenBehaviour.cs b/tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddOpenBehavior.cs
similarity index 72%
rename from tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddOpenBehaviour.cs
rename to tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddOpenBehavior.cs
index c994a4a..0340597 100644
--- a/tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddOpenBehaviour.cs
+++ b/tests/Cqrs.Tests/CqrsServicesExtensionsTests/AddOpenBehavior.cs
@@ -3,10 +3,10 @@ using Microsoft.Extensions.DependencyInjection;
namespace Cqrs.Tests.CqrsServicesExtensionsTests;
-public class AddOpenBehaviour
+public class AddOpenBehavior
{
[ExcludeFromCodeCoverage]
- public class TestOpenBehaviour : IDispatchBehaviour
+ public class TestOpenBehavior : IDispatchBehavior
where TRequest: notnull
{
public ValueTask Handle(TRequest request, DispatchFurtherDelegate next, CancellationToken cancellationToken)
@@ -19,27 +19,27 @@ public class AddOpenBehaviour
[InlineData(ServiceLifetime.Transient)]
[InlineData(ServiceLifetime.Scoped)]
[InlineData(ServiceLifetime.Singleton)]
- public void WhenCalled_ShouldRegisterOpenDispatchBehaviour(ServiceLifetime lifetime)
+ public void WhenCalled_ShouldRegisterOpenDispatchBehavior(ServiceLifetime lifetime)
{
// Given
ServiceCollection services = new();
// When
services.AddCqrs(opt => opt
- .AddOpenBehaviour(typeof(TestOpenBehaviour<,>), lifetime));
+ .AddOpenBehavior(typeof(TestOpenBehavior<,>), lifetime));
// Then
services.ShouldContain(
elementPredicate: descriptor =>
- descriptor.ServiceType == typeof(IDispatchBehaviour<,>)
- && descriptor.ImplementationType == typeof(TestOpenBehaviour<,>)
+ descriptor.ServiceType == typeof(IDispatchBehavior<,>)
+ && descriptor.ImplementationType == typeof(TestOpenBehavior<,>)
&& descriptor.Lifetime == lifetime,
expectedCount: 1
);
}
[ExcludeFromCodeCoverage]
- public class InvalidOpenBehaviour : IDispatchBehaviour
+ public class InvalidOpenBehavior : IDispatchBehavior
{
public Type RequestType => throw new NotImplementedException();
@@ -53,18 +53,18 @@ public class AddOpenBehaviour
ServiceCollection services = new();
// When
- var invalidOpenDispatchBehaviourType = typeof(InvalidOpenBehaviour);
+ var invalidOpenDispatchBehaviorType = typeof(InvalidOpenBehavior);
// Then
Should.Throw(() => services.AddCqrs(opt => opt
- .AddOpenBehaviour(invalidOpenDispatchBehaviourType))
+ .AddOpenBehavior(invalidOpenDispatchBehaviorType))
);
}
public class TestCommand {}
public class TestCommandResult {}
[ExcludeFromCodeCoverage]
- public class NonGenericTestOpenBehaviour : IDispatchBehaviour
+ public class NonGenericTestOpenBehavior : IDispatchBehavior
{
public ValueTask Handle(TestCommand request, DispatchFurtherDelegate next, CancellationToken cancellationToken)
{
@@ -79,11 +79,11 @@ public class AddOpenBehaviour
ServiceCollection services = new();
// When
- var nonGenericOpenDispatchBehaviourType = typeof(NonGenericTestOpenBehaviour);
+ var nonGenericOpenDispatchBehaviorType = typeof(NonGenericTestOpenBehavior);
// Then
Should.Throw(() => services.AddCqrs(opt => opt
- .AddOpenBehaviour(nonGenericOpenDispatchBehaviourType))
+ .AddOpenBehavior(nonGenericOpenDispatchBehaviorType))
);
}
}
diff --git a/tests/Cqrs.Tests/QueryDispatcherImplTests/Dispatch.cs b/tests/Cqrs.Tests/QueryDispatcherImplTests/Dispatch.cs
index 5a74a90..e0eb5b2 100644
--- a/tests/Cqrs.Tests/QueryDispatcherImplTests/Dispatch.cs
+++ b/tests/Cqrs.Tests/QueryDispatcherImplTests/Dispatch.cs
@@ -42,12 +42,12 @@ public class Dispatch
await queryHandler.Received(1).Handle(testQuery, CancellationToken.None);
}
- public class TestOpenBehaviour : IDispatchBehaviour
+ public class TestOpenBehavior : IDispatchBehavior
where TRequest : notnull
{
private readonly Action _callback;
- public TestOpenBehaviour(Action callback)
+ public TestOpenBehavior(Action callback)
{
_callback = callback;
}
@@ -60,7 +60,7 @@ public class Dispatch
}
[Fact]
- public async Task WhenPipelineConfigured_ShouldCallAllBehavioursInOrder()
+ public async Task WhenPipelineConfigured_ShouldCallAllBehaviorsInOrder()
{
// Given
var testQuery = new TestQuery();
@@ -72,15 +72,15 @@ public class Dispatch
.Returns(testQueryResult)
.AndDoes(_ => calls.Add("queryHandler"));
- var firstBehaviour = Substitute.For>();
- firstBehaviour.Handle(testQuery, Arg.Any>(), Arg.Any())
+ var firstBehavior = Substitute.For>();
+ firstBehavior.Handle(testQuery, Arg.Any>(), Arg.Any())
.Returns(args => ((DispatchFurtherDelegate)args[1]).Invoke())
- .AndDoes(_ => calls.Add("firstBehaviour"));
+ .AndDoes(_ => calls.Add("firstBehavior"));
- var secondBehaviour = Substitute.For>();
- secondBehaviour.Handle(testQuery, Arg.Any>(), Arg.Any())
+ var secondBehavior = Substitute.For>();
+ secondBehavior.Handle(testQuery, Arg.Any>(), Arg.Any())
.Returns(args => ((DispatchFurtherDelegate)args[1]).Invoke())
- .AndDoes(_ => calls.Add("secondBehaviour"));
+ .AndDoes(_ => calls.Add("secondBehavior"));
ServiceCollection serviceCollection =
[
@@ -90,22 +90,22 @@ public class Dispatch
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour),
- (IServiceProvider _) => firstBehaviour,
+ typeof(IDispatchBehavior),
+ (IServiceProvider _) => firstBehavior,
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour),
- (IServiceProvider _) => secondBehaviour,
+ typeof(IDispatchBehavior),
+ (IServiceProvider _) => secondBehavior,
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour<,>),
- typeof(TestOpenBehaviour<,>),
+ typeof(IDispatchBehavior<,>),
+ typeof(TestOpenBehavior<,>),
ServiceLifetime.Transient
),
];
- serviceCollection.AddTransient>(_ => (TestQuery _) => calls.Add("thirdBehaviour"));
+ serviceCollection.AddTransient>(_ => (TestQuery _) => calls.Add("thirdBehavior"));
var services = serviceCollection.BuildServiceProvider();
var sut = new QueryDispatcherImpl(services, new ConcurrentMethodsCache());
@@ -115,11 +115,11 @@ public class Dispatch
// Then
result.ShouldBeSameAs(testQueryResult);
- await firstBehaviour.Received(1).Handle(testQuery, Arg.Any>(), Arg.Any());
- await secondBehaviour.Received(1).Handle(testQuery, Arg.Any>(), Arg.Any());
+ await firstBehavior.Received(1).Handle(testQuery, Arg.Any>(), Arg.Any());
+ await secondBehavior.Received(1).Handle(testQuery, Arg.Any>(), Arg.Any());
await queryHandler.Received(1).Handle(testQuery, CancellationToken.None);
- calls.ShouldBe(["firstBehaviour", "secondBehaviour", "thirdBehaviour", "queryHandler"]);
+ calls.ShouldBe(["firstBehavior", "secondBehavior", "thirdBehavior", "queryHandler"]);
}
[Fact]
@@ -136,15 +136,15 @@ public class Dispatch
.Returns(testQueryResult)
.AndDoes(_ => calls.Add("queryHandler"));
- var firstBehaviour = Substitute.For>();
- firstBehaviour.Handle(testQuery, Arg.Any>(), Arg.Any())
+ var firstBehavior = Substitute.For>();
+ firstBehavior.Handle(testQuery, Arg.Any>(), Arg.Any())
.Returns(args => ((DispatchFurtherDelegate)args[1]).Invoke())
- .AndDoes(_ => calls.Add("firstBehaviour"));
+ .AndDoes(_ => calls.Add("firstBehavior"));
- var secondBehaviour = Substitute.For>();
- secondBehaviour.Handle(testQuery, Arg.Any>(), Arg.Any())
+ var secondBehavior = Substitute.For>();
+ secondBehavior.Handle(testQuery, Arg.Any>(), Arg.Any())
.Returns(args => ValueTask.FromResult(testQueryResultAborted))
- .AndDoes(_ => calls.Add("secondBehaviour"));
+ .AndDoes(_ => calls.Add("secondBehavior"));
ServiceCollection serviceCollection =
[
@@ -154,22 +154,22 @@ public class Dispatch
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour),
- (IServiceProvider _) => firstBehaviour,
+ typeof(IDispatchBehavior),
+ (IServiceProvider _) => firstBehavior,
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour),
- (IServiceProvider _) => secondBehaviour,
+ typeof(IDispatchBehavior),
+ (IServiceProvider _) => secondBehavior,
ServiceLifetime.Transient
),
new ServiceDescriptor(
- typeof(IDispatchBehaviour<,>),
- typeof(TestOpenBehaviour<,>),
+ typeof(IDispatchBehavior<,>),
+ typeof(TestOpenBehavior<,>),
ServiceLifetime.Transient
),
];
- serviceCollection.AddTransient>(_ => (TestQuery _) => calls.Add("thirdBehaviour"));
+ serviceCollection.AddTransient>(_ => (TestQuery _) => calls.Add("thirdBehavior"));
var services = serviceCollection.BuildServiceProvider();
var sut = new QueryDispatcherImpl(services, new ConcurrentMethodsCache());
@@ -179,10 +179,10 @@ public class Dispatch
// Then
result.ShouldBeSameAs(testQueryResultAborted);
- await firstBehaviour.Received(1).Handle(testQuery, Arg.Any>(), Arg.Any());
- await secondBehaviour.Received(1).Handle(testQuery, Arg.Any>(), Arg.Any());
+ await firstBehavior.Received(1).Handle(testQuery, Arg.Any>(), Arg.Any());
+ await secondBehavior.Received(1).Handle(testQuery, Arg.Any>(), Arg.Any());
await queryHandler.Received(0).Handle(testQuery, CancellationToken.None);
- calls.ShouldBe(["firstBehaviour", "secondBehaviour"]);
+ calls.ShouldBe(["firstBehavior", "secondBehavior"]);
}
}