예제 #1
0
        public void AndNoVmStoredInSession_ThenLevyStatusShouldBeNonLevy()
        {
            var sessionService = new Mock <ISessionService>();

            sessionService.Setup(ss => ss.Get <LevyOptionViewModel>(sessionService.Object.LevyOptionViewModelKey)).Returns(default(LevyOptionViewModel));

            var controller = new FundingAnApprenticeshipController(sessionService.Object);

            var result = controller.Index();

            result.As <ViewResult>().Model.As <LevyOptionViewModel>().LevyStatus.Should().BeNull();
        }
예제 #2
0
        public void AndNoVmStoredInSession_ThenDefaultVmReturnedInView()
        {
            var sessionService = new Mock <ISessionService>();

            sessionService.Setup(ss => ss.Get <LevyOptionViewModel>(sessionService.Object.LevyOptionViewModelKey)).Returns(default(LevyOptionViewModel));

            var controller = new FundingAnApprenticeshipController(sessionService.Object);

            var result = controller.Index();

            result.As <ViewResult>().Model.As <LevyOptionViewModel>().OptionChosenByUser.Should().BeFalse();
        }
예제 #3
0
        public async Task Then_Vm_Is_Stored_In_Session(
            LevyOptionViewModel model,
            GetMenuQueryResult <Menu> mediatorResult,
            [Frozen] Mock <IMediator> mediator,
            [Frozen] Mock <ISessionService> sessionService,
            [Greedy] FundingAnApprenticeshipController controller)
        {
            //Act
            await controller.Index(model);

            //Assert
            sessionService.Verify(ss => ss.Set(sessionService.Object.LevyOptionViewModelKey, model), Times.Once());
            mediator.Verify(x => x.Send(It.IsAny <GetMenuQuery>(), CancellationToken.None), Times.Never);
        }
예제 #4
0
        public void ThenVmIsStoredInSession()
        {
            var sessionService = new Mock <ISessionService>();
            var controller     = new FundingAnApprenticeshipController(sessionService.Object);

            var levyOptionViewModel = new LevyOptionViewModel()
            {
                LevyStatus = LevyStatus.Levy
            };

            controller.Index(levyOptionViewModel);

            sessionService.Verify(ss => ss.Set(sessionService.Object.LevyOptionViewModelKey, levyOptionViewModel), Times.Once());
        }
예제 #5
0
        public void AndLevyStatusIsSavedAsNonLevy_ThenViewModelLevyStatusIsNonLevy()
        {
            var sessionService = new Mock <ISessionService>();

            sessionService.Setup(ss => ss.Get <LevyOptionViewModel>(sessionService.Object.LevyOptionViewModelKey)).Returns(new LevyOptionViewModel
            {
                LevyStatus = LevyStatus.NonLevy
            });

            var controller = new FundingAnApprenticeshipController(sessionService.Object);

            var result = controller.Index();

            result.As <ViewResult>().Model.As <LevyOptionViewModel>().LevyStatus.Should().Be(LevyStatus.NonLevy);
        }
예제 #6
0
        public async Task Then_If_There_Is_An_Error_The_Menu_Is_Built(
            LevyOptionViewModel model,
            GetMenuQueryResult <Menu> mediatorResult,
            [Frozen] Mock <IMediator> mediator,
            [Greedy] FundingAnApprenticeshipController controller)
        {
            //Arrange
            mediator.Setup(x => x.Send(It.IsAny <GetMenuQuery>(), CancellationToken.None))
            .ReturnsAsync(mediatorResult);
            controller.ModelState.AddModelError("TestError", "Error");

            //Act
            var actual = await controller.Index(model) as ViewResult;

            //Assert
            mediator.Verify(x => x.Send(It.IsAny <GetMenuQuery>(), CancellationToken.None), Times.Once);
            Assert.IsNotNull(actual);
            var actualModel = actual.Model as LevyOptionViewModel;

            Assert.IsNotNull(actualModel);
            actualModel.Menu.Should().BeEquivalentTo(mediatorResult.Page.Menu);
        }