public Task <ValidationResponse> Validate(SubmitAssessorOutcomeCommand command)
        {
            var validationResponse = new ValidationResponse
            {
                Errors = new List <ValidationErrorDetail>()
            };

            if (string.IsNullOrWhiteSpace(command.MoveToModeration))
            {
                validationResponse.Errors.Add(new ValidationErrorDetail(nameof(command.MoveToModeration), $"Select if you're sure this application is ready for moderation"));
            }
            else
            {
                switch (command.MoveToModeration)
                {
                case "YES":
                case "NO":
                    break;

                default:
                    validationResponse.Errors.Add(new ValidationErrorDetail(nameof(command.MoveToModeration), $"Unknown option selected"));
                    break;
                }
            }

            return(Task.FromResult(validationResponse));
        }
        public async Task POST_AssessorOutcome_When_MoveToModeration_NO_redirects_to_Application_Overview()
        {
            // arrange
            var command = new SubmitAssessorOutcomeCommand {
                ApplicationId = _applicationId, MoveToModeration = "NO"
            };

            // act
            var result = await _controller.AssessorOutcome(_applicationId, command) as RedirectToActionResult;

            // assert
            Assert.AreEqual("AssessorOverview", result.ControllerName);
            Assert.AreEqual("ViewApplication", result.ActionName);
        }
        public async Task POST_AssessorOutcome_When_MoveToModeration_YES_redirects_to_AssessmentComplete()
        {
            // arrange
            var command = new SubmitAssessorOutcomeCommand {
                ApplicationId = _applicationId, MoveToModeration = "YES"
            };

            // act
            var result = await _controller.AssessorOutcome(_applicationId, command) as RedirectToActionResult;

            // assert
            Assert.AreEqual("AssessorOutcome", result.ControllerName);
            Assert.AreEqual("AssessmentComplete", result.ActionName);
        }
        public async Task POST_AssessorOutcome_When_MoveToModeration_INVALID_returns_view_with_errors()
        {
            // arrange
            var command = new SubmitAssessorOutcomeCommand {
                ApplicationId = _applicationId, MoveToModeration = "INVALID"
            };

            // act
            var result = await _controller.AssessorOutcome(_applicationId, command) as ViewResult;

            var actualViewModel = result?.Model as AssessorApplicationViewModel;

            // assert
            Assert.That(result, Is.Not.Null);
            Assert.That(actualViewModel, Is.Not.Null);
            Assert.That(_controller.ModelState.IsValid, Is.False);
            Assert.That(_controller.ModelState.ErrorCount, Is.AtLeast(1));
        }
 public void SetUp()
 {
     _validator = new AssessorOutcomeValidator();
     _command   = new SubmitAssessorOutcomeCommand();
 }