public async void NotUsingFixedDate_TimeNowIsWithinOneOfTheQuarterWindow_ReturnTrue()
        {
            var systemData = new SubmissionWindowClosedTests.TestSystemData();
            systemData.ToggleFixedCurrentDateUsage(false);

            A.CallTo(() => systemDataDataAccess.Get())
                .Returns(systemData);

            var timeNow = new DateTime(2016, 4, 10, 0, 0, 0);

            var windowStart = new DateTime(2016, 4, 1, 0, 0, 0);
            var windowEnd = new DateTime(2017, 3, 16, 0, 0, 0);

            A.CallTo(() => quarterWindowFactory.GetQuarterWindowsForDate(A<DateTime>._))
                .Returns(new List<QuarterWindow>
                {
                    new QuarterWindow(windowStart, windowEnd)
                });

            SystemTime.Freeze(timeNow, true);

            var handler = new IsSubmissionWindowOpenHandler(quarterWindowFactory, systemDataDataAccess);

            var result = await handler.HandleAsync(A.Dummy<IsSubmissionWindowOpen>());

            SystemTime.Unfreeze();

            Assert.True(result);
        }
Beispiel #2
0
        public async void NotUsingFixedDate_TimeNowIsWithinOneOfTheQuarterWindow_ReturnTrue()
        {
            var systemData = new SubmissionWindowClosedTests.TestSystemData();

            systemData.ToggleFixedCurrentDateUsage(false);

            A.CallTo(() => systemDataDataAccess.Get())
            .Returns(systemData);

            var timeNow = new DateTime(2016, 4, 10, 0, 0, 0);

            var windowStart = new DateTime(2016, 4, 1, 0, 0, 0);
            var windowEnd   = new DateTime(2017, 3, 16, 0, 0, 0);

            A.CallTo(() => quarterWindowFactory.GetQuarterWindowsForDate(A <DateTime> ._))
            .Returns(new List <QuarterWindow>
            {
                new QuarterWindow(windowStart, windowEnd, QuarterType.Q1)
            });

            SystemTime.Freeze(timeNow, true);

            var handler = new IsSubmissionWindowOpenHandler(quarterWindowFactory, systemDataDataAccess);

            var result = await handler.HandleAsync(A.Dummy <IsSubmissionWindowOpen>());

            SystemTime.Unfreeze();

            Assert.True(result);
        }
        public async void GetApiDate_UseFixedCurrentDateIsTrue_ReturnFixedDate()
        {
            var systemData = new SubmissionWindowClosedTests.TestSystemData();
            var fixedDate = new DateTime(2018, 4, 10, 0, 0, 0);
            systemData.UpdateFixedCurrentDate(fixedDate);
            systemData.ToggleFixedCurrentDateUsage(true);

            A.CallTo(() => systemDataDataAccess.Get())
                .Returns(systemData);
           
            var handler = new GetApiDateHandler(systemDataDataAccess);

            var result = await handler.HandleAsync(A.Dummy<GetApiDate>());

            Assert.Equal(result, fixedDate);
        }
        public async void GetApiUtcDate_UseFixedCurrentDateIsTrue_ReturnFixedDate()
        {
            var systemData = new SubmissionWindowClosedTests.TestSystemData();
            var fixedDate  = new DateTime(2018, 4, 10, 0, 0, 0);

            systemData.UpdateFixedCurrentDate(fixedDate);
            systemData.ToggleFixedCurrentDateUsage(true);

            A.CallTo(() => systemDataDataAccess.Get())
            .Returns(systemData);

            var handler = new GetApiUtcDateHandler(systemDataDataAccess);

            var result = await handler.HandleAsync(A.Dummy <GetApiUtcDate>());

            Assert.Equal(result, fixedDate);
        }
        public async void GetApiDate_UseFixedCurrentDateIsFalse_ReturnCurrentDate()
        {
            var systemData = new SubmissionWindowClosedTests.TestSystemData();
            systemData.ToggleFixedCurrentDateUsage(false);

            A.CallTo(() => systemDataDataAccess.Get())
                .Returns(systemData);

            var timeNow = new DateTime(2016, 4, 10, 0, 0, 0);

            SystemTime.Freeze(timeNow, true);

            var handler = new GetApiDateHandler(systemDataDataAccess);

            var result = await handler.HandleAsync(A.Dummy<GetApiDate>());

            SystemTime.Unfreeze();

            Assert.Equal(result.ToUniversalTime().Date, timeNow.ToUniversalTime().Date);
        }
        public async void GetApiUtcDate_UseFixedCurrentDateIsFalse_ReturnCurrentDate()
        {
            var systemData = new SubmissionWindowClosedTests.TestSystemData();

            systemData.ToggleFixedCurrentDateUsage(false);

            A.CallTo(() => systemDataDataAccess.Get())
            .Returns(systemData);

            var timeNow = new DateTime(2016, 4, 10, 0, 0, 0);

            SystemTime.Freeze(timeNow, true);

            var handler = new GetApiUtcDateHandler(systemDataDataAccess);

            var result = await handler.HandleAsync(A.Dummy <GetApiUtcDate>());

            SystemTime.Unfreeze();

            Assert.Equal(result.ToUniversalTime().Date, timeNow.ToUniversalTime().Date);
        }