Exemplo n.º 1
0
        public async Task <ActionResult> SubmitForReviewAsync([Required] string id)
        {
            SubmitSolutionForReviewCommandResult result = await mediator.Send(new SubmitSolutionForReviewCommand(id));

            return(result.IsSuccess
                ? NoContent()
                : (ActionResult)BadRequest(SubmitSolutionForReviewResult.Create(result.Errors)));
        }
        public async Task SubmitForReviewResultFailure()
        {
            var expectedErrorList = new List <ValidationError> {
                SubmitSolutionForReviewErrors.SolutionSummaryIsRequired
            };

            var expected = SubmitSolutionForReviewResult.Create(new ReadOnlyCollection <ValidationError>(expectedErrorList));

            SetupMockMediator(new SubmitSolutionForReviewCommandResult(expectedErrorList));

            var result = await solutionsController.SubmitForReviewAsync(SolutionId) as BadRequestObjectResult;

            Assert.NotNull(result);
            result.StatusCode.Should().Be(StatusCodes.Status400BadRequest);

            var actual = result.Value as SubmitSolutionForReviewResult;

            Assert.NotNull(actual);
            actual.RequiredSections.Should().BeEquivalentTo(expected.RequiredSections);
        }
 public void NullErrorsShouldThrowNullException()
 {
     Assert.Throws <ArgumentNullException>(() => SubmitSolutionForReviewResult.Create(null));
 }