< Summary

Information
Class: ArturRios.Util.Test.Mock.FakeScheduler
Assembly: ArturRios.Util.Test
File(s): D:\Repositories\dotnet-test-util\src\Mock\FakeScheduler.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 40
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 3
Fully covered methods: 1
Total methods: 3
Method coverage: 100%
Full method coverage: 33.3%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
CreateCommandSchedule()100%11100%
CreateQuerySchedule()100%11100%

File(s)

D:\Repositories\dotnet-test-util\src\Mock\FakeScheduler.cs

#LineLine coverage
 1using ArturRios.Mediator;
 2using ArturRios.Mediator.Command;
 3using ArturRios.Mediator.Query;
 4
 5namespace ArturRios.Util.Test.Mock;
 6
 7/// <summary>
 8/// Test helper that simulates a delayed (scheduled) dispatch of a command or query through a
 9/// <see cref="CommandQueryMediator"/>. Use a small <paramref name="waitTimeInSeconds"/> to keep tests fast.
 10/// </summary>
 11/// <param name="mediator">The mediator used to dispatch the command or query.</param>
 12/// <param name="waitTimeInSeconds">The delay, in seconds, applied before dispatching. Defaults to 60.</param>
 313public class FakeScheduler(CommandQueryMediator mediator, int waitTimeInSeconds = 60)
 14{
 15    /// <summary>Waits for the configured delay and then dispatches <paramref name="command"/>.</summary>
 16    /// <typeparam name="TCommand">The command type.</typeparam>
 17    /// <typeparam name="TCommandOutput">The command output type.</typeparam>
 18    /// <param name="command">The command to dispatch.</param>
 19    public async Task CreateCommandSchedule<TCommand, TCommandOutput>(TCommand command)
 20        where TCommand : BaseCommand
 21        where TCommandOutput : CommandOutput
 222    {
 223        await Task.Delay(TimeSpan.FromSeconds(waitTimeInSeconds));
 24
 225        await mediator.ExecuteCommandAsync<TCommand, TCommandOutput>(command);
 226    }
 27
 28    /// <summary>Waits for the configured delay and then dispatches <paramref name="query"/>.</summary>
 29    /// <typeparam name="TQuery">The query type.</typeparam>
 30    /// <typeparam name="TQueryOutput">The query output type.</typeparam>
 31    /// <param name="query">The query to dispatch.</param>
 32    public async Task CreateQuerySchedule<TQuery, TQueryOutput>(TQuery query)
 33        where TQuery : BaseQuery
 34        where TQueryOutput : QueryOutput
 135    {
 136        await Task.Delay(TimeSpan.FromSeconds(waitTimeInSeconds));
 37
 138        await mediator.ExecuteQueryAsync<TQuery, TQueryOutput>(query);
 139    }
 40}