Example #1
0
        public void Map_GivenExistingNonObligatedAlreadySelected_MappedObjectShouldSetDcfSelectedValueToNo()
        {
            var questions       = new List <ReportOnQuestion>();
            var returnReportOns = new List <ReturnReportOn>();

            var @return = A.Fake <ReturnData>();

            @return.Quarter       = new Quarter(2019, QuarterType.Q1);
            @return.QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow();

            for (var i = 0; i < 4; i++)
            {
                questions.Add(this.fixture.Build <ReportOnQuestion>().With(r => r.Id, i + 1).Create());
                returnReportOns.Add(new ReturnReportOn(i + 1, @return.Id));
            }

            @return.ReturnReportOns = returnReportOns;

            var result = this.map.Map(new ReportOptionsToSelectReportOptionsViewModelMapTransfer()
            {
                OrganisationId = Guid.NewGuid(), ReturnId = Guid.NewGuid(), ReportOnQuestions = questions, ReturnData = @return
            });

            result.ReportOnQuestions.Count.Should().Be(4);
            result.ReportOnQuestions.ElementAt(0).Id.Should().Be(1);
            result.ReportOnQuestions.ElementAt(0).Selected.Should().Be(true);
            result.ReportOnQuestions.ElementAt(1).Id.Should().Be(2);
            result.ReportOnQuestions.ElementAt(1).Selected.Should().Be(true);
            result.ReportOnQuestions.ElementAt(2).Id.Should().Be(3);
            result.ReportOnQuestions.ElementAt(2).Selected.Should().Be(true);
            result.ReportOnQuestions.ElementAt(3).Id.Should().Be(4);
            result.ReportOnQuestions.ElementAt(3).Selected.Should().Be(true);
            result.DcfSelectedValue = DcfNoValue;
        }
Example #2
0
        public void Map_GivenReturnsData_ViewModelReturnsShouldBeOrderedByYearThenQuarterThenCreatedDate()
        {
            var returnData = new List <ReturnData>()
            {
                new ReturnData()
                {
                    CreatedDate = new DateTime(2017),
                    Quarter     = new Quarter(2020, QuarterType.Q4), QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
                },
                new ReturnData()
                {
                    CreatedDate = new DateTime(2019),
                    Quarter     = new Quarter(2020, QuarterType.Q4), QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
                },
                new ReturnData()
                {
                    CreatedDate = new DateTime(2018),
                    Quarter     = new Quarter(2020, QuarterType.Q4), QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
                },
                new ReturnData()
                {
                    CreatedDate = new DateTime(2020),
                    Quarter     = new Quarter(2020, QuarterType.Q4), QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
                }
            };

            var result = ordering.Order(returnData);

            result.ElementAt(0).CreatedDate.Should().Be(new DateTime(2020));
            result.ElementAt(1).CreatedDate.Should().Be(new DateTime(2019));
            result.ElementAt(2).CreatedDate.Should().Be(new DateTime(2018));
            result.ElementAt(3).CreatedDate.Should().Be(new DateTime(2017));
        }
Example #3
0
        public void Map_GivenReturnData_ReturnPropertiesShouldBeMapped()
        {
            var returnData = this.fixture.Build <ReturnData>()
                             .With(r => r.Quarter, new Quarter(2019, QuarterType.Q1))
                             .With(r => r.QuarterWindow, QuarterWindowTestHelper.GetDefaultQuarterWindow())
                             .With(r => r.ReturnReportOns, ((List <ReturnReportOn>)null))
                             .Create();

            var organisationId  = this.fixture.Create <Guid>();
            var returnId        = this.fixture.Create <Guid>();
            var reportQuestions = this.fixture.CreateMany <ReportOnQuestion>().ToList();

            var result = this.map.Map(new ReportOptionsToSelectReportOptionsViewModelMapTransfer()
            {
                OrganisationId = organisationId, ReturnId = returnId, ReturnData = returnData, ReportOnQuestions = reportQuestions
            });

            result.OrganisationId.Should().Be(organisationId);
            result.ReturnId.Should().Be(returnId);
            result.ReportOnQuestions.Should().BeSameAs(reportQuestions);
            result.ReturnData.Should().Be(returnData);
            result.Year.Should().Be(returnData.Quarter.Year.ToString());
            result.QuarterWindowEndDate.Should().Be(returnData.QuarterWindow.QuarterEnd);
            result.QuarterWindowStartDate.Should().Be(returnData.QuarterWindow.QuarterStart);
            result.Quarter.Should().Be(returnData.Quarter.Q.ToString());
        }
Example #4
0
        public async void OnActionExecuting_GivenReturnStatusIsCreatedAndQuarterWindowForReturnIsClosed_ContextResultReturnsErrorPage()
        {
            var returnStatusData = new ReturnStatusData()
            {
                OrganisationId = Guid.NewGuid(),
                ReturnStatus   = ReturnStatus.Created
            };

            SystemTime.Freeze(new DateTime(2019, 04, 01));

            var returnData = new ReturnData()
            {
                QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
            };

            A.CallTo(() => client.SendAsync(A <string> ._,
                                            A <GetReturnStatus> .That.Matches(r => r.ReturnId.Equals((Guid)context.RouteData.Values["returnId"])))).Returns(returnStatusData);

            A.CallTo(() => client.SendAsync(A <string> ._,
                                            A <GetReturn> .That.Matches(r => r.ReturnId.Equals((Guid)context.RouteData.Values["returnId"])))).Returns(returnData);

            await attribute.OnAuthorizationAsync(context, (Guid)context.RouteData.Values["returnId"]);

            SystemTime.Unfreeze();

            RedirectResult result = context.Result as RedirectResult;

            Assert.Equal("~/errors/QuarterClosed", result.Url);
        }
Example #5
0
        public void Map_GivenReturnsData_ViewModelReturnsShouldBeOrderedByYearThenQuarter()
        {
            var returnData = new List <ReturnData>()
            {
                new ReturnData()
                {
                    Quarter = new Quarter(2020, QuarterType.Q2), QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
                },
                new ReturnData()
                {
                    Quarter = new Quarter(2020, QuarterType.Q1), QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
                },
                new ReturnData()
                {
                    Quarter = new Quarter(2020, QuarterType.Q4), QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
                },
                new ReturnData()
                {
                    Quarter = new Quarter(2020, QuarterType.Q3), QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
                }
            };

            var result = ordering.Order(returnData);

            result.ElementAt(0).Quarter.Q.Should().Be(QuarterType.Q4);
            result.ElementAt(1).Quarter.Q.Should().Be(QuarterType.Q3);
            result.ElementAt(2).Quarter.Q.Should().Be(QuarterType.Q2);
            result.ElementAt(3).Quarter.Q.Should().Be(QuarterType.Q1);
        }
        private ReturnsData GetDefaultReturnData(List <ReturnData> returnsList)
        {
            var openQuarters = new List <Quarter>();
            var nextQuarter  = QuarterWindowTestHelper.GetDefaultQuarterWindow();

            return(new ReturnsData(returnsList, null, openQuarters, nextQuarter, fixture.Create <DateTime>()));
        }
        public async void IndexGet_GivenValidViewModel_BreadcrumbShouldBeSet()
        {
            var          organisationId   = Guid.NewGuid();
            var          @return          = A.Fake <ReturnData>();
            var          organisationData = A.Fake <OrganisationData>();
            const string orgName          = "orgName";

            var          quarterData     = new Quarter(2019, QuarterType.Q1);
            var          quarterWindow   = QuarterWindowTestHelper.GetDefaultQuarterWindow();
            const string reportingPeriod = "2019 Q1 Jan - Mar";

            @return.Quarter       = quarterData;
            @return.QuarterWindow = quarterWindow;

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);
            A.CallTo(() => organisationData.Id).Returns(organisationId);
            A.CallTo(() => @return.OrganisationData).Returns(organisationData);
            A.CallTo(() => cache.FetchOrganisationName(organisationId)).Returns(orgName);

            await controller.Index(A.Dummy <Guid>(), A.Dummy <bool>());

            breadcrumb.ExternalActivity.Should().Be(BreadCrumbConstant.AatfReturn);
            breadcrumb.ExternalOrganisation.Should().Be(orgName);
            breadcrumb.OrganisationId.Should().Be(organisationId);

            Assert.Contains(reportingPeriod, breadcrumb.QuarterDisplayInfo);
        }
        public void Map_GivenMappedReturnsAreEditableAndThereAreNoInProgressReturnInComplianceYearAndQuarter_ReturnedShouldBeEditable()
        {
            var returnData = A.CollectionOfFake <ReturnData>(1).ToList();

            var returnsItems = new List <ReturnsItemViewModel>()
            {
                new ReturnsItemViewModel()
                {
                    ReturnViewModel = new ReturnViewModel(new ReturnData()
                    {
                        Quarter = new Quarter(2019, QuarterType.Q1), QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
                    }, new List <AatfObligatedData>(), A.Fake <OrganisationData>(), new TaskListDisplayOptions()),
                    ReturnsListDisplayOptions = new ReturnsListDisplayOptions()
                    {
                        DisplayEdit = true
                    },
                }
            };

            A.CallTo(() => ordering.Order(A <List <ReturnData> > ._)).Returns(returnData);
            A.CallTo(() => returnItemViewModelMap.Map(A <ReturnData> ._)).ReturnsNextFromSequence(returnsItems.ToArray());

            var returnsData = new ReturnsData(returnData, null, A.Fake <List <Quarter> >(), QuarterWindowTestHelper.GetDefaultQuarterWindow(),
                                              DateTime.Now);

            var result = returnsMap.Map(new ReturnToReturnsViewModelTransfer()
            {
                ReturnsData = returnsData
            });

            result.Returns.ElementAt(0).ReturnsListDisplayOptions.DisplayEdit.Should().BeTrue();
        }
Example #9
0
        public void Map_GivenExistingReturnReportOns_MappedObjectShouldUpdatedReportOnQuestions()
        {
            var questions       = new List <ReportOnQuestion>();
            var returnReportOns = new List <ReturnReportOn>();

            var @return = A.Fake <ReturnData>();

            @return.Quarter       = new Quarter(2019, QuarterType.Q1);
            @return.QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow();

            for (var i = 0; i < 5; i++)
            {
                questions.Add(this.fixture.Build <ReportOnQuestion>().With(r => r.Id, i + 1).Create());
                returnReportOns.Add(new ReturnReportOn(i + 1, @return.Id));
            }

            @return.ReturnReportOns = returnReportOns;

            var result = this.map.Map(new ReportOptionsToSelectReportOptionsViewModelMapTransfer()
            {
                OrganisationId = Guid.NewGuid(), ReturnId = Guid.NewGuid(), ReportOnQuestions = questions, ReturnData = @return
            });

            this.AssertValues(result, true);
        }
Example #10
0
        public async void IndexGet_GivenValidViewModel_BreadcrumbShouldBeSet()
        {
            var          organisationId = Guid.NewGuid();
            const string orgName        = "orgName";

            var @return       = A.Fake <ReturnData>();
            var quarterData   = new Quarter(2019, QuarterType.Q1);
            var quarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow();
            var aatfInfo      = A.Fake <AatfData>();
            var aatfId        = Guid.NewGuid();

            const string reportingQuarter = "2019 Q1 Jan - Mar";
            const string reportingPeriod  = "Test (WEE/QW1234RE/ATF)";

            @return.Quarter       = quarterData;
            @return.QuarterWindow = quarterWindow;
            const string aatfName = "Test";

            aatfInfo.ApprovalNumber = "WEE/QW1234RE/ATF";

            A.CallTo(() => cache.FetchOrganisationName(organisationId)).Returns(orgName);

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);
            A.CallTo(() => cache.FetchAatfData(organisationId, aatfId)).Returns(aatfInfo);
            A.CallTo(() => aatfInfo.Name).Returns(aatfName);

            await controller.Index(organisationId, A.Dummy <Guid>(), aatfId, A.Dummy <Guid?>());

            breadcrumb.ExternalActivity.Should().Be(BreadCrumbConstant.AatfReturn);
            breadcrumb.ExternalOrganisation.Should().Be(orgName);
            breadcrumb.OrganisationId.Should().Be(organisationId);

            Assert.Contains(reportingQuarter, breadcrumb.QuarterDisplayInfo);
            Assert.Contains(reportingPeriod, breadcrumb.AatfDisplayInfo);
        }
        public void Map_GivenReturnStatusIsCreated_QuarterOpen_DisplayOptionsShouldBeSet()
        {
            var displayOptions = mapper.Map((ReturnStatus.Created, QuarterWindowTestHelper.GetDefaultQuarterWindow(), new DateTime(2019, 04, 01)));

            displayOptions.DisplayContinue.Should().BeTrue();
            displayOptions.DisplayEdit.Should().BeFalse();
            displayOptions.DisplaySummary.Should().BeFalse();
        }
        public void Constructor_GivenReturnStatusIsSubmitted_QuarterClosed_DisplayOptionsShouldBeSet()
        {
            var displayOptions = mapper.Map((ReturnStatus.Submitted, QuarterWindowTestHelper.GetDefaultQuarterWindow(), new DateTime(2019, 3, 1)));

            displayOptions.DisplayContinue.Should().BeFalse();
            displayOptions.DisplayEdit.Should().BeFalse();
            displayOptions.DisplaySummary.Should().BeTrue();
        }
Example #13
0
        public void FormatQuarter_BasedOnParameters()
        {
            var quarterData   = new Quarter(2019, QuarterType.Q1);
            var quarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow();

            var value = DisplayHelper.YearQuarterPeriodFormat(quarterData, quarterWindow);

            Assert.Equal("2019 Q1 Jan - Mar", value);
        }
        private IPostprocessComposer <ReturnAndAatfToSentOnCreateSiteViewModelMapTransfer> CreateDefaultTransferObject()
        {
            var returnData = fixture.Build <ReturnData>()
                             .With(r => r.Quarter, new Quarter(2019, QuarterType.Q1))
                             .With(r => r.QuarterWindow, QuarterWindowTestHelper.GetDefaultQuarterWindow())
                             .Create();

            var source = fixture.Build <ReturnAndAatfToSentOnCreateSiteViewModelMapTransfer>()
                         .With(r => r.Return, returnData);

            return(source);
        }
Example #15
0
        public async void IndexGet_GivenReturn_ReturnsSummaryViewModelShouldBeBuilt()
        {
            var @return = fixture.Build <ReturnData>()
                          .With(r => r.Quarter, new Quarter(DateTime.Now.Year, QuarterType.Q1))
                          .With(r => r.QuarterWindow, QuarterWindowTestHelper.GetDefaultQuarterWindow())
                          .Create();

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);

            await controller.Index(A.Dummy <Guid>());

            A.CallTo(() => mapper.Map <ReturnViewModel>(@return)).MustHaveHappened(Repeated.Exactly.Once);
        }
Example #16
0
        public async void IndexGet_GivenActionExecutes_DefaultViewShouldBeReturned()
        {
            var @return = fixture.Build <ReturnData>()
                          .With(r => r.Quarter, new Quarter(DateTime.Now.Year, QuarterType.Q1))
                          .With(r => r.QuarterWindow, QuarterWindowTestHelper.GetDefaultQuarterWindow())
                          .Create();

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);

            var result = await controller.Index(A.Dummy <Guid>()) as ViewResult;

            result.ViewName.Should().Be("Index");
        }
Example #17
0
        public void SubmittedReturnViewModel_GivenQuarterIsNull_ArgumentNullExceptionExpected()
        {
            var returnData = new ReturnData()
            {
                QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow()
            };

            Action action = () =>
            {
                var submittedReturnViewModel = new SubmittedReturnViewModel(returnData);
            };

            action.Should().Throw <ArgumentNullException>();
        }
Example #18
0
        public async void IndexGet_GivenValidViewModel_BreadcrumbShouldBeSet()
        {
            var returnId = Guid.NewGuid();
            var @return  = fixture.Build <ReturnData>()
                           .With(r => r.Quarter, new Quarter(DateTime.Now.Year, QuarterType.Q1))
                           .With(r => r.QuarterWindow, QuarterWindowTestHelper.GetDefaultQuarterWindow())
                           .Create();

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);

            await controller.Index(returnId);

            Assert.Equal(breadcrumb.ExternalActivity, BreadCrumbConstant.AatfReturn);
        }
Example #19
0
        public void Map_GivenSource_ReturnDisplayOptionsListShouldBeMapped()
        {
            var quarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow();
            var returnData    = new ReturnData()
            {
                ReturnStatus = ReturnStatus.Created, QuarterWindow = quarterWindow, SystemDateTime = DateTime.Now
            };

            var result = mapper.Map(returnData);

            var expectedTuple = (returnData.ReturnStatus, returnData.QuarterWindow, returnData.SystemDateTime);

            A.CallTo(() => genericMapper.Map <ReturnsListDisplayOptions>(expectedTuple)).MustHaveHappened(Repeated.Exactly.Once);
        }
        public void Map_GivenNoReturnQuarter_NoReturns_ErrorMessageDisplayedIsNotExpectedToSubmitReturn()
        {
            var returnData   = new List <ReturnData>();
            var openQuarters = new List <Quarter>();
            var nextQuarter  = QuarterWindowTestHelper.GetDefaultQuarterWindow();

            var returnsData = new ReturnsData(returnData, null, openQuarters, nextQuarter, new DateTime(2019, 3, 1));

            var result = returnsMap.Map(new ReturnToReturnsViewModelTransfer()
            {
                ReturnsData = returnsData
            });

            Assert.Equal("You aren’t expected to submit a return yet. If you think this is wrong, contact your environmental regulator.", result.ErrorMessageForNotAllowingCreateReturn);
        }
Example #21
0
        public async void IndexGet_GivenReturn_ApiShouldBeCalledWithReturnRequest()
        {
            var returnId = Guid.NewGuid();
            var @return  = fixture.Build <ReturnData>()
                           .With(r => r.Quarter, new Quarter(DateTime.Now.Year, QuarterType.Q1))
                           .With(r => r.QuarterWindow, QuarterWindowTestHelper.GetDefaultQuarterWindow())
                           .Create();

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);

            await controller.Index(returnId);

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> .That.Matches(g => g.ReturnId.Equals(returnId))))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Example #22
0
        public async void IndexGet_GivenReturn_ReturnsSummaryViewModelShouldBeReturned()
        {
            var model   = A.Fake <ReturnViewModel>();
            var @return = fixture.Build <ReturnData>()
                          .With(r => r.Quarter, new Quarter(DateTime.Now.Year, QuarterType.Q1))
                          .With(r => r.QuarterWindow, QuarterWindowTestHelper.GetDefaultQuarterWindow())
                          .Create();

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);

            A.CallTo(() => mapper.Map <ReturnViewModel>(A <ReturnData> ._)).Returns(model);

            var result = await controller.Index(A.Dummy <Guid>()) as ViewResult;

            result.Model.Should().Be(model);
        }
Example #23
0
        public async void OnActionExecuting_GivenReturnStatusIsCreated_ContextResultShouldBeNull()
        {
            var returnData = new ReturnData()
            {
                QuarterWindow  = QuarterWindowTestHelper.GetDefaultQuarterWindow(),
                SystemDateTime = new DateTime(2019, 04, 01),
                ReturnStatus   = ReturnStatus.Created
            };

            A.CallTo(() => client.SendAsync(A <string> ._,
                                            A <GetReturn> .That.Matches(r => r.ReturnId.Equals((Guid)context.RouteData.Values["returnId"])))).Returns(returnData);

            await attribute.OnAuthorizationAsync(context, (Guid)context.RouteData.Values["returnId"]);

            context.Result.Should().BeNull();
        }
        public async void IndexGet_GivenValidViewModel_BreadcrumbShouldBeSet()
        {
            var @return = fixture.Build <ReturnData>()
                          .With(r => r.Quarter, new Quarter(2019, QuarterType.Q1))
                          .With(r => r.QuarterWindow, QuarterWindowTestHelper.GetDefaultQuarterWindow())
                          .Create();

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);

            SystemTime.Freeze(new DateTime(2019, 04, 01));
            await controller.Index(A.Dummy <Guid>());

            SystemTime.Unfreeze();

            Assert.Equal(breadcrumb.ExternalActivity, BreadCrumbConstant.AatfReturn);
        }
        public void Map_GivenMappingObjects_ObjectShouldBeMapped()
        {
            var @return = A.Fake <ReturnData>();

            @return.Quarter       = new Quarter(2019, QuarterType.Q1);
            @return.QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow();
            var transfer = new ReturnDataToSelectReportOptionsNilViewModelMapTransfer()
            {
                OrganisationId = Guid.NewGuid(), ReturnId = Guid.NewGuid(), ReturnData = @return
            };

            var result = map.Map(transfer);

            result.Year.Should().Be("2019");
            result.Period.Should().Be("Q1 Jan - Mar");
            result.ReturnId.Should().Be(transfer.ReturnId);
            result.OrganisationId.Should().Be(transfer.OrganisationId);
        }
        public async void IndexGet_GivenActionAndParameters_AatfTaskListViewModelShouldBeReturned()
        {
            var model   = A.Fake <ReturnViewModel>();
            var @return = fixture.Build <ReturnData>()
                          .With(r => r.Quarter, new Quarter(2019, QuarterType.Q1))
                          .With(r => r.QuarterWindow, QuarterWindowTestHelper.GetDefaultQuarterWindow())
                          .Create();

            A.CallTo(() => mapper.Map <ReturnViewModel>(A <ReturnData> ._)).Returns(model);
            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);

            SystemTime.Freeze(new DateTime(2019, 04, 01));
            var result = await controller.Index(A.Dummy <Guid>()) as ViewResult;

            SystemTime.Unfreeze();

            result.Model.Should().BeEquivalentTo(model);
        }
        public async void IndexGet_GivenValidViewModel_MapperIsCalled()
        {
            var organisationId = Guid.NewGuid();
            var returnId       = Guid.NewGuid();

            var returnData = new ReturnData()
            {
                QuarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow(),
                Quarter       = new Quarter(2019, QuarterType.Q1)
            };

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> .That.Matches(r => r.ReturnId == returnId))).Returns(returnData);

            await controller.Index(organisationId, returnId);

            A.CallTo(() => mapper.Map(A <ReturnDataToSelectReportOptionsNilViewModelMapTransfer> .That.Matches(t => t.OrganisationId == organisationId &&
                                                                                                               t.ReturnId == returnId &&
                                                                                                               t.ReturnData == returnData))).MustHaveHappened(Repeated.Exactly.Once);
        }
        public async void IndexGet_GivenValidViewModel_BreadcrumbShouldBeSet()
        {
            var          returnId        = Guid.NewGuid();
            var          organisationId  = Guid.NewGuid();
            var          quarterData     = new Quarter(2019, QuarterType.Q1);
            var          quarterWindow   = QuarterWindowTestHelper.GetDefaultQuarterWindow();
            const string reportingPeriod = "2019 Q1 Jan - Mar";
            var          @return         = A.Fake <ReturnData>();

            @return.Quarter       = quarterData;
            @return.QuarterWindow = quarterWindow;

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(@return);

            await controller.Index(organisationId, returnId);

            Assert.Equal(breadcrumb.ExternalActivity, BreadCrumbConstant.AatfReturn);

            Assert.Contains(reportingPeriod, breadcrumb.QuarterDisplayInfo);
        }
        public void Map_GivenValidSource_PropertiesShouldBeMapped()
        {
            var id = Guid.NewGuid();

            var quarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow();
            var returnData    = new ReturnData()
            {
                Id = id, Quarter = new Quarter(2019, QuarterType.Q1), QuarterWindow = quarterWindow, OrganisationData = new OrganisationData()
                {
                    Id = Guid.NewGuid(), Name = "operator"
                }
            };

            var result = map.Map(returnData);

            result.Quarter.Should().Be("Q1");
            result.Year.Should().Be("2019");
            result.Period.Should().Be("Q1 Jan - Mar 2019");
            result.OrganisationId.Should().Be(returnData.OrganisationData.Id);
        }
        public async void PcsRemovedGet_GiveActionExecutes_BreadCrumbShouldBeSet()
        {
            var returnId       = this.fixture.Create <Guid>();
            var organisationId = this.fixture.Create <Guid>();
            var @return        = this.fixture.Build <ReturnData>().With(r => r.Quarter, new Quarter(2019, QuarterType.Q1)).With(
                r => r.QuarterWindow,
                QuarterWindowTestHelper.GetDefaultQuarterWindow()).Create();

            const string reportingPeriod = "2019 Q1 Jan - Mar";

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> .That.Matches(r => r.ReturnId == returnId && r.ForSummary == false))).Returns(@return);

            SystemTime.Freeze(new DateTime(2019, 04, 01));
            await controller.PcsRemoved(organisationId, returnId);

            SystemTime.Unfreeze();

            Assert.Equal(breadcrumb.ExternalActivity, BreadCrumbConstant.AatfReturn);

            Assert.Contains(reportingPeriod, breadcrumb.QuarterDisplayInfo);
        }