public async void GetReview_WithDataReturnWithNoErrors_RedirectsToSubmit() { // Arrange DataReturnForSubmission dataReturnForSubmission = new DataReturnForSubmission( new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A"), new Guid("DDE08793-D655-4CDD-A87A-083307C1AA66"), 2015, QuarterType.Q4, A.Dummy <IReadOnlyCollection <DataReturnWarning> >(), A.Dummy <IReadOnlyCollection <DataReturnError> >(), false); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <FetchDataReturnForSubmission> ._)) .WhenArgumentsMatch(args => args.Get <FetchDataReturnForSubmission>("request").DataReturnUploadId == new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A")) .Returns(dataReturnForSubmission); DataReturnsController controller = GetDummyDataReturnsController(weeeClient); // Act ActionResult result = await controller.Review( new Guid("DDE08793-D655-4CDD-A87A-083307C1AA66"), new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A")); // Assert Assert.IsAssignableFrom <RedirectToRouteResult>(result); RedirectToRouteResult redirectToRouteResult = result as RedirectToRouteResult; Assert.Equal("Submit", redirectToRouteResult.RouteValues["action"]); Assert.Equal(new Guid("DDE08793-D655-4CDD-A87A-083307C1AA66"), redirectToRouteResult.RouteValues["pcsId"]); Assert.Equal(new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A"), redirectToRouteResult.RouteValues["dataReturnUploadId"]); }
public async void GetReview_WithDataReturnWithDifferentOrganisationId_ThrowsAnException() { // Arrange DataReturnForSubmission dataReturnForSubmission = new DataReturnForSubmission( new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A"), new Guid("DDE08793-D655-4CDD-A87A-083307C1AA66"), 2015, QuarterType.Q4, A.Dummy <IReadOnlyCollection <DataReturnWarning> >(), A.Dummy <IReadOnlyCollection <DataReturnError> >(), false); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <FetchDataReturnForSubmission> ._)) .WhenArgumentsMatch(args => args.Get <FetchDataReturnForSubmission>("request").DataReturnUploadId == new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A")) .Returns(dataReturnForSubmission); DataReturnsController controller = GetDummyDataReturnsController(weeeClient); // Act Func <Task <ActionResult> > testCode = async() => await controller.Review( new Guid("AA7DA88A-19AF-4130-A24D-45389D97B274"), new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A")); // Assert await Assert.ThrowsAnyAsync <Exception>(testCode); }
public async void GetReview_HappyPath_ReturnsSubmitViewWithPopulatedViewModel() { // Arrange DataReturnError error = new DataReturnError("Test Error"); DataReturnForSubmission dataReturnForSubmission = new DataReturnForSubmission( new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A"), new Guid("DDE08793-D655-4CDD-A87A-083307C1AA66"), 2015, QuarterType.Q4, A.Dummy <IReadOnlyCollection <DataReturnWarning> >(), new List <DataReturnError>() { error }, false); A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <FetchDataReturnForSubmission> ._)) .WhenArgumentsMatch(args => args.Get <FetchDataReturnForSubmission>("request").DataReturnUploadId == new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A")) .Returns(dataReturnForSubmission); DataReturnsController controller = GetDummyDataReturnsController(weeeClient); // Act ActionResult result = await controller.Review( new Guid("DDE08793-D655-4CDD-A87A-083307C1AA66"), new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A")); // Assert Assert.IsAssignableFrom <ViewResultBase>(result); ViewResultBase viewResult = result as ViewResultBase; Assert.True(viewResult.ViewName == "Submit", "The GET Review action must return the view called \"Submit\" when the data return has no errors."); Assert.IsAssignableFrom <SubmitViewModel>(viewResult.Model); SubmitViewModel viewModel = viewResult.Model as SubmitViewModel; Assert.Equal(dataReturnForSubmission, viewModel.DataReturn); }