public void WhenMadeRedundantConfirmedIsTrue_ThenValidatorReturnsValid(MadeRedundantViewModel viewModel) { viewModel.MadeRedundant = true; var result = _validator.Validate(viewModel); Assert.True(result.IsValid); }
public void WhenMadeRedundantConfirmedIsNull_ThenValidatorReturnsInvalid(MadeRedundantViewModel viewModel) { viewModel.MadeRedundant = null; var result = _validator.Validate(viewModel); Assert.False(result.IsValid); }
public async Task WhenRequesting_HasTheAppretniceBeenMadeRedundant_ThenMadeRedundantViewModelIsPassedToTheView(MadeRedundantViewModel expectedViewModel) { _mockModelMapper.Setup(m => m.Map <MadeRedundantViewModel>(It.IsAny <MadeRedundantRequest>())) .ReturnsAsync(expectedViewModel); var viewResult = await _controller.HasTheApprenticeBeenMadeRedundant(new MadeRedundantRequest()) as ViewResult; var viewModel = viewResult.Model; var actualViewModel = (MadeRedundantViewModel)viewModel; Assert.IsInstanceOf <MadeRedundantViewModel>(viewModel); Assert.AreEqual(expectedViewModel, actualViewModel); }
public void AndTheUserAnswered_HasTheApprenticeBeenMadeRedundant_ThenRedirectToConfirmStopApprenticeship(MadeRedundantViewModel viewModel) { var result = _controller.HasTheApprenticeBeenMadeRedundant(viewModel); var redirect = result.VerifyReturnsRedirectToActionResult(); Assert.AreEqual(redirect.ActionName, "ConfirmStop"); Assert.AreEqual(redirect.RouteValues["AccountHashedId"], viewModel.AccountHashedId); Assert.AreEqual(redirect.RouteValues["ApprenticeshipHashedId"], viewModel.ApprenticeshipHashedId); Assert.AreEqual(redirect.RouteValues["StopMonth"], viewModel.StopMonth); Assert.AreEqual(redirect.RouteValues["StopYear"], viewModel.StopYear); Assert.AreEqual(redirect.RouteValues["IsCoPJourney"], viewModel.IsCoPJourney); Assert.AreEqual(redirect.RouteValues["MadeRedundant"], viewModel.MadeRedundant); }
public IActionResult HasTheApprenticeBeenMadeRedundant(MadeRedundantViewModel viewModel) { return(RedirectToAction(nameof(ConfirmStop), new { viewModel.AccountHashedId, viewModel.ApprenticeshipHashedId, viewModel.IsCoPJourney, viewModel.StopMonth, viewModel.StopYear, viewModel.MadeRedundant })); }