Exemple #1
0
        public ActionResult ChooseReport(ChooseReportTypeModel model)
        {
            SetBreadcrumb();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            switch (model.SelectedValue)
            {
            case Reports.PcsReports:
                return(RedirectToAction("Index", "SchemeReports"));

            case Reports.AatfReports:
                return(RedirectToAction("Index", "AatfReports"));

            case Reports.PcsAatfDataDifference:
                return(RedirectToAction(nameof(PcsAatfDataDifference), "Reports"));

            case Reports.AatfAeDetails:
                return(RedirectToAction(nameof(AatfAeDetails), "Reports"));

            default:
                throw new NotSupportedException();
            }
        }
Exemple #2
0
        public ActionResult ChooseReport()
        {
            SetBreadcrumb();

            var model = new ChooseReportTypeModel();

            return(View(model));
        }
        public void ChooseReportTypeModel_ShouldHaveValidOptions()
        {
            var model = new ChooseReportTypeModel();

            model.PossibleValues.Count.Should().Be(4);
            model.PossibleValues.ElementAt(0).Should().Be(Reports.PcsReports);
            model.PossibleValues.ElementAt(1).Should().Be(Reports.AatfReports);
            model.PossibleValues.ElementAt(2).Should().Be(Reports.PcsAatfDataDifference);
            model.PossibleValues.ElementAt(3).Should().Be(Reports.AatfAeDetails);
        }
        public void PostChooseReport_WithInvalidSelectedValue_ThrowsNotSupportedException()
        {
            // Arrange
            var controller = new ReportsController(
                () => A.Dummy <IWeeeClient>(),
                A.Dummy <BreadcrumbService>());

            // Act
            var model = new ChooseReportTypeModel {
                SelectedValue = "SOME INVALID VALUE"
            };
            Func <ActionResult> testCode = () => controller.ChooseReport(model);

            // Assert
            Assert.Throws <NotSupportedException>(testCode);
        }
        public void PostChooseReport_WithSelectedValue_RedirectsToExpectedAction(string selectedValue, string expectedAction, string expectedController)
        {
            // Arrange
            var controller = new ReportsController(
                () => A.Dummy <IWeeeClient>(),
                A.Dummy <BreadcrumbService>());

            // Act
            var model = new ChooseReportTypeModel {
                SelectedValue = selectedValue
            };
            var result = controller.ChooseReport(model);

            // Assert
            var redirectResult = result as RedirectToRouteResult;

            Assert.NotNull(redirectResult);

            Assert.Equal(expectedAction, redirectResult.RouteValues["action"]);
            Assert.Equal(expectedController, redirectResult.RouteValues["controller"]);
        }