Example #1
0
        public async void GetSubmit_HappyPath_ReturnsSubmitViewWithPopulatedViewModel()
        {
            // Arrange
            DataReturnForSubmission dataReturnForSubmission = new DataReturnForSubmission(
                new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A"),
                new Guid("AA7DA88A-19AF-4130-A24D-45389D97B274"),
                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.Submit(
                new Guid("AA7DA88A-19AF-4130-A24D-45389D97B274"),
                new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A"));

            // Assert
            Assert.IsAssignableFrom <ViewResultBase>(result);
            ViewResultBase viewResult = result as ViewResultBase;

            Assert.True(viewResult.ViewName == string.Empty || viewResult.ViewName == "Submit",
                        "The GET Submit action must return the view called \"Submit\".");

            Assert.IsAssignableFrom <SubmitViewModel>(viewResult.Model);
            SubmitViewModel viewModel = viewResult.Model as SubmitViewModel;

            Assert.Equal(dataReturnForSubmission, viewModel.DataReturn);
        }
Example #2
0
        public async void GetSubmit_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.Submit(
                new Guid("AA7DA88A-19AF-4130-A24D-45389D97B274"),
                new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A"));

            // Assert
            await Assert.ThrowsAnyAsync <Exception>(testCode);
        }
Example #3
0
        public async void PostSubmit_HappyPath_RedirectsToSuccessfulSubmission()
        {
            // Arrange
            DataReturnsController controller = GetDummyDataReturnsController(weeeClient);

            // Act
            ActionResult result = await controller.Submit(
                new Guid("AA7DA88A-19AF-4130-A24D-45389D97B274"),
                new Guid("06FFB265-46D3-4CE3-805A-A81F1B11622A"),
                new SubmitViewModel());

            // Assert
            Assert.IsAssignableFrom <RedirectToRouteResult>(result);
            RedirectToRouteResult redirectToRouteResult = result as RedirectToRouteResult;

            Assert.Equal("SuccessfulSubmission", redirectToRouteResult.RouteValues["action"]);
            Assert.Equal(new Guid("AA7DA88A-19AF-4130-A24D-45389D97B274"), redirectToRouteResult.RouteValues["pcsId"]);
        }
Example #4
0
        public async void GetSubmit_WithDataReturnWithErrors_RedirectsToReview()
        {
            // 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.Submit(
                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("Review", 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"]);
        }