Example #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);
    }
 public NearDeadlineRecurringAction(NearDeadLineMonitor monitor, ILogger <NearDeadlineRecurringAction> logger)
 {
     _monitor = monitor;
     _logger  = logger;
 }