Beispiel #1
0
        public async Task HandleAsync_OpenQuartersShouldBeReturned()
        {
            var message       = new GetReturns(Guid.NewGuid(), Core.AatfReturn.FacilityType.Aatf);
            var returnQuarter = new Quarter(2019, QuarterType.Q1);

            List <Domain.DataReturns.QuarterWindow> openWindows = new List <Domain.DataReturns.QuarterWindow>()
            {
                new Domain.DataReturns.QuarterWindow(new DateTime(2019, 04, 01), new DateTime(2019, 06, 01), Domain.DataReturns.QuarterType.Q1)
            };

            Domain.DataReturns.QuarterWindow nextWindow = new Domain.DataReturns.QuarterWindow(new DateTime(2019, 06, 01), new DateTime(2019, 09, 01), Domain.DataReturns.QuarterType.Q2);

            A.CallTo(() => returnFactory.GetReturnQuarter(message.OrganisationId, message.Facility)).Returns(returnQuarter);

            DateTime date = new DateTime(2019, 04, 01);

            SystemTime.Freeze(date);

            A.CallTo(() => quarterWindowFactory.GetQuarterWindowsForDate(date)).Returns(openWindows);
            A.CallTo(() => quarterWindowFactory.GetNextQuarterWindow(Domain.DataReturns.QuarterType.Q1, 2019)).Returns(nextWindow);

            var result = await handler.HandleAsync(message);

            SystemTime.Unfreeze();

            result.OpenQuarters.Count.Should().Be(1);
            result.OpenQuarters[0].Q.Should().Be(QuarterType.Q1);
            result.OpenQuarters[0].Year.Should().Be(returnQuarter.Year);

            A.CallTo(() => quarterWindowFactory.GetQuarterWindowsForDate(date)).MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #2
0
        public async Task HandleAsync_OpenQuarters_WorkOutNextWindow()
        {
            var message       = new GetReturns(Guid.NewGuid(), Core.AatfReturn.FacilityType.Aatf);
            var returnQuarter = new Quarter(2019, QuarterType.Q1);

            Domain.DataReturns.QuarterWindow nextWindow = new Domain.DataReturns.QuarterWindow(new DateTime(2019, 07, 01), new DateTime(2020, 03, 16), Domain.DataReturns.QuarterType.Q2);

            List <Domain.DataReturns.QuarterWindow> openWindows = new List <Domain.DataReturns.QuarterWindow>()
            {
                new Domain.DataReturns.QuarterWindow(new DateTime(2019, 04, 01), new DateTime(2020, 03, 16), Domain.DataReturns.QuarterType.Q1)
            };

            A.CallTo(() => returnFactory.GetReturnQuarter(message.OrganisationId, message.Facility)).Returns(returnQuarter);

            DateTime date = new DateTime(2019, 04, 01);

            SystemTime.Freeze(date);

            A.CallTo(() => quarterWindowFactory.GetQuarterWindowsForDate(date)).Returns(openWindows);
            A.CallTo(() => quarterWindowFactory.GetNextQuarterWindow(openWindows[0].QuarterType, date.Year)).Returns(nextWindow);

            var result = await handler.HandleAsync(message);

            SystemTime.Unfreeze();

            result.NextWindow.WindowOpenDate.Should().Be(nextWindow.StartDate);
            result.NextWindow.WindowClosedDate.Should().Be(nextWindow.EndDate);
            A.CallTo(() => quarterWindowFactory.GetNextQuarterWindow(openWindows[0].QuarterType, date.Year)).MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #3
0
 private static Expression <Func <T, bool> > Predicate <T>(QuarterWindow quarterWindow, Return returnCopy) where T : AatfEntity
 {
     return(w => (w.Aatf.ApprovalDate == null || w.Aatf.ApprovalDate.Value >= quarterWindow.StartDate) && w.ReturnId == returnCopy.Id);
 }