Exemplo n.º 1
0
    public async Task OnlyPublishesOnceForSecondGameweekWhenFirstGameweekIsCurrent()
    {
        var fakeSettingsClient = A.Fake <IGlobalSettingsClient>();
        var gameweek1          = new Gameweek {
            IsCurrent = true, IsNext = false, Deadline = new DateTime(2021, 8, 15, 10, 0, 0)
        };
        var gameweek2 = new Gameweek {
            IsCurrent = false, IsNext = true, Deadline = new DateTime(2021, 8, 22, 10, 0, 0)
        };
        var globalSettings = new GlobalSettings {
            Gameweeks = new List <Gameweek> {
                gameweek1, gameweek2
            }
        };

        A.CallTo(() => fakeSettingsClient.GetGlobalSettings()).Returns(globalSettings);
        var session        = new TestableMessageSession();
        var dontCareLogger = A.Fake <ILogger <NearDeadLineMonitor> >();
        var dateTimeUtils  = new DateTimeUtils {
            NowUtcOverride = new DateTime(2021, 8, 21, 10, 0, 0)
        };

        var handler = new NearDeadLineMonitor(fakeSettingsClient, dateTimeUtils, session, dontCareLogger);

        await handler.EveryMinuteTick();

        Assert.Single(session.PublishedMessages);
        Assert.IsType <TwentyFourHoursToDeadline>(session.PublishedMessages[0].Message);
    }
Exemplo n.º 2
0
 public async Task Process(CancellationToken token)
 {
     using var scope  = _logger.BeginCorrelationScope();
     using var scope2 = _logger.AddContext("NeardeadlineCheck");
     _logger.LogInformation($"Running {nameof(NearDeadlineRecurringAction)}");
     await _monitor.EveryMinuteTick();
 }