예제 #1
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);
        }
예제 #2
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());
        }
예제 #3
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);
        }