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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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
                }));
            }
        }
Exemplo n.º 6
0
        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);
            }
        }