public async void IndexPost_OnSubmitWithNoSelected_PageRedirectsToSelectReportOptions() { var httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); var organisationId = Guid.NewGuid(); var returnId = Guid.NewGuid(); var viewModel = CreateSubmittedViewModel(); viewModel.ReturnId = returnId; viewModel.OrganisationId = organisationId; httpContext.RouteData.Values.Add("organisationId", organisationId); httpContext.RouteData.Values.Add("returnId", returnId); A.CallTo(() => mapper.Map(A <SelectReportOptionsViewModel> ._)).Returns(viewModel); controller.TempData["viewModel"] = CreateTempData(); var result = await controller.Index(viewModel) as RedirectToRouteResult; result.RouteValues["action"].Should().Be("Index"); result.RouteValues["organisationId"].Should().Be(organisationId); result.RouteValues["returnId"].Should().Be(returnId); }
public async void IndexPost_OnSubmitWithOnePastedValues_TempDataShouldBeAttached() { var httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); var schemeId = Guid.NewGuid(); var returnId = Guid.NewGuid(); var aatfId = Guid.NewGuid(); var viewModel = new ObligatedValuesCopyPasteViewModel { SchemeId = schemeId, ReturnId = returnId, AatfId = aatfId, B2bPastedValues = new String[1] { "2\n" }, B2cPastedValues = new String[1] }; await controller.Index(viewModel); controller.TempData["pastedValues"].Should().NotBeNull(); }
public async void IndexPost_OnSubmitYesSelectedAndWeeeReceivedNotReSelected_PageRedirectsToAatfTaskList() { var httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); var organisationId = Guid.NewGuid(); var returnId = Guid.NewGuid(); var model = A.Fake <SelectReportOptionsDeselectViewModel>(); var reportsOn = A.CollectionOfFake <ReportOnQuestion>(1); A.CallTo(() => model.OrganisationId).Returns(organisationId); A.CallTo(() => model.ReturnId).Returns(returnId); A.CallTo(() => reportsOn.ElementAt(0).Id).Returns((int)ReportOnQuestionEnum.WeeeReceived); A.CallTo(() => reportsOn.ElementAt(0).ReSelected).Returns(false); A.CallTo(() => model.SelectedValue).Returns(model.YesValue); httpContext.RouteData.Values.Add("organisationId", organisationId); httpContext.RouteData.Values.Add("returnId", returnId); A.CallTo(() => mapper.Map(A <SelectReportOptionsViewModel> ._)).Returns(model); controller.TempData["viewModel"] = CreateTempData(); var result = await controller.Index(model) as RedirectToRouteResult; result.RouteValues["action"].Should().Be("Index"); result.RouteValues["controller"].Should().Be("AatfTaskList"); result.RouteValues["returnId"].Should().Be(returnId); }
public async void IndexPost_OnSubmit_PageRedirectsToSiteList() { var httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); var organisationId = Guid.NewGuid(); var returnId = Guid.NewGuid(); var aatfId = Guid.NewGuid(); var viewModel = new ReusedOffSiteCreateSiteViewModel { OrganisationId = organisationId, ReturnId = returnId, AatfId = aatfId, }; httpContext.RouteData.Values.Add("organisationId", organisationId); httpContext.RouteData.Values.Add("returnId", returnId); httpContext.RouteData.Values.Add("aatfId", aatfId); var result = await controller.Index(viewModel) as RedirectToRouteResult; result.RouteValues["action"].Should().Be("Index"); result.RouteValues["controller"].Should().Be("ReusedOffSiteSummaryList"); result.RouteValues["organisationId"].Should().Be(organisationId); result.RouteValues["returnId"].Should().Be(returnId); result.RouteValues["aatfId"].Should().Be(aatfId); }
public async void IndexPost_FromReused_OnSubmit_PageRedirectsToObligatedReused() { HttpContextMocker httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); Guid returnId = Guid.NewGuid(); Guid aatfId = Guid.NewGuid(); ObligatedValuesCopyPasteViewModel viewModel = new ObligatedValuesCopyPasteViewModel { ReturnId = returnId, AatfId = aatfId, B2bPastedValues = new String[1], B2cPastedValues = new String[1], Type = ObligatedType.Reused }; httpContext.RouteData.Values.Add("returnId", returnId); httpContext.RouteData.Values.Add("aatfId", aatfId); RedirectToRouteResult result = await controller.Index(viewModel) as RedirectToRouteResult; result.RouteValues["action"].Should().Be("Index"); result.RouteValues["controller"].Should().Be("ObligatedReused"); result.RouteValues["returnId"].Should().Be(returnId); result.RouteValues["aatfId"].Should().Be(aatfId); }
public async void IndexPost_OnSubmit_PageRedirectsToObligatedReceived() { HttpContextMocker httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); Guid returnId = Guid.NewGuid(); Guid aatfId = Guid.NewGuid(); string siteName = "site name"; ObligatedSentOnValuesCopyPasteViewModel viewModel = new ObligatedSentOnValuesCopyPasteViewModel { SiteName = siteName, ReturnId = returnId, AatfId = aatfId, B2bPastedValues = new string[1], B2cPastedValues = new string[1] }; httpContext.RouteData.Values.Add("returnId", returnId); httpContext.RouteData.Values.Add("aatfId", aatfId); RedirectToRouteResult result = await controller.Index(viewModel) as RedirectToRouteResult; result.RouteValues["action"].Should().Be("Index"); result.RouteValues["controller"].Should().Be("ObligatedSentOn"); result.RouteValues["returnId"].Should().Be(returnId); result.RouteValues["aatfId"].Should().Be(aatfId); }
public async void IndexPost_OnSubmitWithOnePastedValues_TempDataShouldBeAttached() { HttpContextMocker httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); Guid returnId = Guid.NewGuid(); Guid aatfId = Guid.NewGuid(); string siteName = "site name"; ObligatedSentOnValuesCopyPasteViewModel viewModel = new ObligatedSentOnValuesCopyPasteViewModel { SiteName = siteName, ReturnId = returnId, AatfId = aatfId, B2bPastedValues = new string[1] { "2\n" }, B2cPastedValues = new string[1] }; await controller.Index(viewModel); controller.TempData["pastedValues"].Should().NotBeNull(); }
public async void IndexPost_OnSubmitWithPcsOptionSelectedAndPreviousPcsSelection_PageRedirectsToAatfTaskList() { var httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); var organisationId = Guid.NewGuid(); var returnId = Guid.NewGuid(); var model = A.Fake <SelectReportOptionsViewModel>(); var reportsOn = A.CollectionOfFake <ReportOnQuestion>(1); var schemeDataItems = A.CollectionOfFake <SchemeData>(1); var returnData = new ReturnData() { SchemeDataItems = schemeDataItems }; A.CallTo(() => reportsOn.ElementAt(0).Id).Returns((int)ReportOnQuestionEnum.WeeeReceived); A.CallTo(() => reportsOn.ElementAt(0).Selected).Returns(true); A.CallTo(() => model.ReportOnQuestions).Returns(reportsOn); A.CallTo(() => model.OrganisationId).Returns(organisationId); A.CallTo(() => model.ReturnId).Returns(returnId); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(returnData); httpContext.RouteData.Values.Add("organisationId", organisationId); httpContext.RouteData.Values.Add("returnId", returnId); var result = await controller.Index(model) as RedirectToRouteResult; result.RouteValues["action"].Should().Be("Index"); result.RouteValues["controller"].Should().Be("AatfTaskList"); result.RouteValues["returnId"].Should().Be(returnId); }
private void SetupControllerRequest() { var mocker = new HttpContextMocker(); mocker.AttachToController(controller); var request = A.Fake <HttpRequestBase>(); A.CallTo(() => mocker.HttpContextBase.Request).Returns(request); }
private void SetupControllerAjaxRequest() { var mocker = new HttpContextMocker(); mocker.AttachToController(controller); var request = A.Fake <HttpRequestBase>(); A.CallTo(() => mocker.HttpContextBase.Request).Returns(request); A.CallTo(() => request["X-Requested-With"]).Returns("XMLHttpRequest"); }
public async void IndexPost_OnSubmitWithNoPastedValues_TempDataShouldNotBeAttached() { var httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); var returnId = Guid.NewGuid(); var viewModel = new NonObligatedValuesCopyPasteViewModel { ReturnId = returnId, PastedValues = new string[1] }; await controller.Index(viewModel); controller.TempData["pastedValues"].Should().BeNull(); }
public async void IndexPost_GivenNonObligatedQuestionIsNotSelectedAndModelIsNotValid_DcfSelectedValueShouldBeRemovedFromModelState() { var httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); var model = CreateSubmittedViewModel(); model.ReportOnQuestions.First(r => r.Id == (int)ReportOnQuestionEnum.NonObligated).Selected = false; controller.ModelState.AddModelError("error", "error"); controller.ModelState.Add("DcfSelectedValue", new ModelState()); controller.ModelState.SetModelValue("DcfSelectedValue", new ValueProviderResult("Yes", string.Empty, CultureInfo.InvariantCulture)); await controller.Index(model); controller.ModelState.Where(m => m.Key.Equals("DcfSelectedValue")).Should().BeNullOrEmpty(); }
public async void IndexPost_OnSubmitDcf_PageRedirectsToNonObligatedDcf() { var httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); var returnId = Guid.NewGuid(); var viewModel = new NonObligatedValuesCopyPasteViewModel { ReturnId = returnId, PastedValues = new string[1], Dcf = true }; httpContext.RouteData.Values.Add("returnId", returnId); var result = await controller.Index(viewModel) as RedirectToRouteResult; result.RouteName.Should().Be("aatf-non-obligated-dcf"); result.RouteValues["returnId"].Should().Be(returnId); result.RouteValues["dcf"].Should().Be(true); }
public async void IndexPost_OnSubmitWithDeselectedOptionAndSelectedOption_PageRedirectsToSelectReportOptionsDeselect() { var httpContext = new HttpContextMocker(); httpContext.AttachToController(controller); var organisationId = Guid.NewGuid(); var returnId = Guid.NewGuid(); var model = A.Fake <SelectReportOptionsViewModel>(); A.CallTo(() => model.OrganisationId).Returns(organisationId); A.CallTo(() => model.ReturnId).Returns(returnId); A.CallTo(() => model.DeSelectedOptions).Returns(new List <int>() { 1 }); A.CallTo(() => model.HasSelectedOptions).Returns(true); var returnData = new ReturnData { ReturnReportOns = new List <ReturnReportOn>() }; for (var i = 0; i < 5; i++) { returnData.ReturnReportOns.Add(new ReturnReportOn(i + 1, returnId)); } A.CallTo(() => weeeClient.SendAsync(A <String> ._, A <GetReturn> ._)).Returns(returnData); httpContext.RouteData.Values.Add("organisationId", organisationId); httpContext.RouteData.Values.Add("returnId", returnId); var result = await controller.Index(model) as RedirectToRouteResult; result.RouteValues["action"].Should().Be("Index"); result.RouteValues["returnId"].Should().Be(returnId); result.RouteValues["organisationId"].Should().Be(organisationId); result.RouteName.Should().Be(AatfRedirect.SelectReportOptionsDeselectRouteName); }