Example #1
0
        public void PostChooseActivity_WithInvalidModel_ReturnsChooseActivityViewWithViewModelAndAddsAuthorityToViewBag()
        {
            // Arrange
            ChargeController controller = new ChargeController(
                A.Dummy <IAppConfiguration>(),
                A.Dummy <BreadcrumbService>(),
                () => A.Dummy <IWeeeClient>());

            controller.ModelState.AddModelError("key", "Some error");

            // Act
            ActionResult result = controller.ChooseActivity(CompetentAuthority.NorthernIreland, A.Dummy <ChooseActivityViewModel>());

            // Assert
            ViewResult viewResult = result as ViewResult;

            Assert.NotNull(viewResult);

            Assert.True(viewResult.ViewName == string.Empty || viewResult.ViewName == "ChooseActivity");

            ChooseActivityViewModel viewModel = viewResult.Model as ChooseActivityViewModel;

            Assert.NotNull(viewModel);

            Assert.Equal(CompetentAuthority.NorthernIreland, (object)viewResult.ViewBag.Authority);
        }
Example #2
0
        public void PostChooseActivity_WithViewInvoiceRunHistorySelected_RedirectsToInvoiceRunsActionWithSelectedAuthority()
        {
            // Arrange
            ChargeController controller = new ChargeController(
                A.Dummy <IAppConfiguration>(),
                A.Dummy <BreadcrumbService>(),
                () => A.Dummy <IWeeeClient>());

            ChooseActivityViewModel viewModel = new ChooseActivityViewModel();

            viewModel.SelectedActivity = Activity.ViewInvoiceRunHistory;

            // Act
            ActionResult result = controller.ChooseActivity(CompetentAuthority.NorthernIreland, viewModel);

            // Assert
            RedirectToRouteResult redirectResult = result as RedirectToRouteResult;

            Assert.NotNull(redirectResult);

            Assert.Equal("InvoiceRuns", redirectResult.RouteValues["action"]);
            Assert.Equal(CompetentAuthority.NorthernIreland, redirectResult.RouteValues["authority"]);
        }
        public void PostChooseActivity_WithViewInvoiceRunHistorySelected_RedirectsToInvoiceRunsActionWithSelectedAuthority()
        {
            // Arrange
            ChargeController controller = new ChargeController(
                A.Dummy<IAppConfiguration>(),
                A.Dummy<BreadcrumbService>(),
                () => A.Dummy<IWeeeClient>());

            ChooseActivityViewModel viewModel = new ChooseActivityViewModel();
            viewModel.SelectedActivity = Activity.ViewInvoiceRunHistory;

            // Act
            ActionResult result = controller.ChooseActivity(CompetentAuthority.NorthernIreland, viewModel);

            // Assert
            RedirectToRouteResult redirectResult = result as RedirectToRouteResult;
            Assert.NotNull(redirectResult);

            Assert.Equal("InvoiceRuns", redirectResult.RouteValues["action"]);
            Assert.Equal(CompetentAuthority.NorthernIreland, redirectResult.RouteValues["authority"]);
        }
        public void PostChooseActivity_WithInvalidModel_ReturnsChooseActivityViewWithViewModelAndAddsAuthorityToViewBag()
        {
            // Arrange
            ChargeController controller = new ChargeController(
                A.Dummy<IAppConfiguration>(),
                A.Dummy<BreadcrumbService>(),
                () => A.Dummy<IWeeeClient>());

            controller.ModelState.AddModelError("key", "Some error");

            // Act
            ActionResult result = controller.ChooseActivity(CompetentAuthority.NorthernIreland, A.Dummy<ChooseActivityViewModel>());

            // Assert
            ViewResult viewResult = result as ViewResult;
            Assert.NotNull(viewResult);

            Assert.True(viewResult.ViewName == string.Empty || viewResult.ViewName == "ChooseActivity");

            ChooseActivityViewModel viewModel = viewResult.Model as ChooseActivityViewModel;
            Assert.NotNull(viewModel);

            Assert.Equal(CompetentAuthority.NorthernIreland, (object)viewResult.ViewBag.Authority);
        }