diff --git a/tests/Immediate.Handler.FunctionalTests/NoBehaviors/ParameterizedTests.cs b/tests/Immediate.Handler.FunctionalTests/NoBehaviors/ParameterizedTests.cs new file mode 100644 index 00000000..8052a993 --- /dev/null +++ b/tests/Immediate.Handler.FunctionalTests/NoBehaviors/ParameterizedTests.cs @@ -0,0 +1,48 @@ +using Immediate.Handlers.Shared; +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace Immediate.Handler.FunctionalTests.NoBehaviors; + +[Handler] +public static partial class NoBehaviorParameterizedOneAdder +{ + public sealed record Query(int Input); + + private static Task HandleAsync( + Query query, + AddendProvider addendProvider, + CancellationToken _) + { + return Task.FromResult(query.Input + addendProvider.Addend); + } +} + +public class AddendProvider +{ +#pragma warning disable CA1822 + public int Addend => 1; +#pragma warning restore CA1822 +} + +public class ParameterizedTests +{ + [Fact] + public async Task NoBehaviorShouldReturnExpectedResponse() + { + const int Input = 1; + + var serviceProvider = new ServiceCollection() + .AddHandlers() + .AddScoped() + .BuildServiceProvider(); + + var handler = serviceProvider.GetRequiredService(); + + var query = new NoBehaviorParameterizedOneAdder.Query(Input); + + var result = await handler.HandleAsync(query); + + Assert.Equal(Input + serviceProvider.GetRequiredService().Addend, result); + } +} \ No newline at end of file diff --git a/tests/Immediate.Handler.FunctionalTests/NoBehaviorTests.cs b/tests/Immediate.Handler.FunctionalTests/NoBehaviors/ParameterlessTests.cs similarity index 57% rename from tests/Immediate.Handler.FunctionalTests/NoBehaviorTests.cs rename to tests/Immediate.Handler.FunctionalTests/NoBehaviors/ParameterlessTests.cs index 36a207e6..24bd62b5 100644 --- a/tests/Immediate.Handler.FunctionalTests/NoBehaviorTests.cs +++ b/tests/Immediate.Handler.FunctionalTests/NoBehaviors/ParameterlessTests.cs @@ -2,10 +2,10 @@ using Microsoft.Extensions.DependencyInjection; using Xunit; -namespace Immediate.Handler.FunctionalTests; +namespace Immediate.Handler.FunctionalTests.NoBehaviors; [Handler] -public static partial class OneAdder +public static partial class NoBehaviorParameterlessOneAdder { public sealed record Query(int Input); @@ -17,21 +17,23 @@ private static Task HandleAsync( } } -public class NoBehaviorTests +public class ParameterlessTests { [Fact] public async Task NoBehaviorShouldReturnExpectedResponse() { + const int Input = 1; + var serviceProvider = new ServiceCollection() .AddHandlers() .BuildServiceProvider(); - var handler = serviceProvider.GetRequiredService(); + var handler = serviceProvider.GetRequiredService(); - var query = new OneAdder.Query(1); + var query = new NoBehaviorParameterlessOneAdder.Query(Input); var result = await handler.HandleAsync(query); - Assert.Equal(query.Input + 1, result); + Assert.Equal(Input + 1, result); } }