public void Validate_ChangeStatusType_WhenNotSelected_ThenItShouldBeInvalid() { var model = new ChangeStatusRequestViewModel { SelectedStatusChange = null }; AssertValidationResult(request => request.SelectedStatusChange, model, false); }
public void Validate_ChangeStatusType_ShouldBeValidated(ChangeStatusType status) { var model = new ChangeStatusRequestViewModel { SelectedStatusChange = status }; AssertValidationResult(request => request.SelectedStatusChange, model, true); }
public void AndPauseIsSelected_ThenRedirectToResumeApprenticeshipAction(ChangeStatusRequestViewModel viewModel) { //Arrange viewModel.SelectedStatusChange = ChangeStatusType.Resume; //Act var response = _controller.ChangeStatus(viewModel) as RedirectToActionResult; //Assert Assert.AreEqual("ResumeApprenticeship", response.ActionName); }
public void AndStopIsSelected_ThenRedirectToV1WhenToApplyStopAction(ChangeStatusRequestViewModel viewModel) { //Arrange viewModel.SelectedStatusChange = ChangeStatusType.Stop; viewModel.CurrentStatus = CommitmentsV2.Types.ApprenticeshipStatus.Live; //Act var response = _controller.ChangeStatus(viewModel) as RedirectToActionResult; //Assert Assert.AreEqual("StopApprenticeship", response.ActionName); }
public IActionResult ChangeStatus(ChangeStatusRequestViewModel viewModel) { switch (viewModel.SelectedStatusChange) { case ChangeStatusType.Pause: return(RedirectToAction(nameof(PauseApprenticeship), new { viewModel.AccountHashedId, viewModel.ApprenticeshipHashedId })); case ChangeStatusType.Stop: var redirectToActionName = viewModel.CurrentStatus == CommitmentsV2.Types.ApprenticeshipStatus.WaitingToStart ? nameof(HasTheApprenticeBeenMadeRedundant) : nameof(StopApprenticeship); return(RedirectToAction(redirectToActionName, new { viewModel.AccountHashedId, viewModel.ApprenticeshipHashedId })); case ChangeStatusType.Resume: return(RedirectToAction(nameof(ResumeApprenticeship), new { viewModel.AccountHashedId, viewModel.ApprenticeshipHashedId })); default: return(RedirectToAction(nameof(ApprenticeshipDetails), new ApprenticeshipDetailsRequest { AccountHashedId = viewModel.AccountHashedId, ApprenticeshipHashedId = viewModel.ApprenticeshipHashedId })); } }
public void AndStopIsSelected_ThenRedirectToV1WhenToHasTheApprenticeBeenMadeRedundant(ChangeStatusRequestViewModel viewModel) { //Arrange viewModel.SelectedStatusChange = ChangeStatusType.Stop; viewModel.CurrentStatus = CommitmentsV2.Types.ApprenticeshipStatus.WaitingToStart; //Act var response = _controller.ChangeStatus(viewModel) as RedirectToActionResult; //Assert Assert.AreEqual("HasTheApprenticeBeenMadeRedundant", response.ActionName); }
private void AssertValidationResult <T>(Expression <Func <ChangeStatusRequestViewModel, T> > property, ChangeStatusRequestViewModel instance, bool expectedValid) { var validator = new ChangeStatusRequestViewModelValidator(); if (expectedValid) { validator.ShouldNotHaveValidationErrorFor(property, instance); } else { validator.ShouldHaveValidationErrorFor(property, instance); } }