public async Task ShouldUpdateValidationInvalid() { var browsersSupportedUpdateViewModel = new UpdateSolutionBrowsersSupportedViewModel(); var validationModel = new RequiredResult() { Required = { "browsers-supported", "mobile-responsive" } }; _mockMediator.Setup(m => m.Send( It.Is <UpdateSolutionBrowsersSupportedCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionBrowsersSupportedViewModel == browsersSupportedUpdateViewModel), It.IsAny <CancellationToken>())) .ReturnsAsync(validationModel); var result = (await _browserSupportedController.UpdateBrowsersSupportedAsync(SolutionId, browsersSupportedUpdateViewModel).ConfigureAwait(false)) as BadRequestObjectResult; result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); (result.Value as UpdateFormRequiredResult).Required.Should().BeEquivalentTo(new[] { "browsers-supported", "mobile-responsive" }); _mockMediator.Verify(m => m.Send(It.Is <UpdateSolutionBrowsersSupportedCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionBrowsersSupportedViewModel == browsersSupportedUpdateViewModel), It.IsAny <CancellationToken>()), Times.Once); }
public async Task ShouldUpdateValidationValid() { var browsersSupportedUpdateViewModel = new UpdateSolutionBrowsersSupportedViewModel(); var validationModel = new RequiredResult(); _mockMediator.Setup(m => m.Send( It.Is <UpdateSolutionBrowsersSupportedCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionBrowsersSupportedViewModel == browsersSupportedUpdateViewModel), It.IsAny <CancellationToken>())) .ReturnsAsync(validationModel); var result = (await _browserSupportedController.UpdateBrowsersSupportedAsync(SolutionId, browsersSupportedUpdateViewModel).ConfigureAwait(false)) as NoContentResult; result?.StatusCode.Should().Be((int)HttpStatusCode.NoContent); _mockMediator.Verify( m => m.Send( It.Is <UpdateSolutionBrowsersSupportedCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionBrowsersSupportedViewModel == browsersSupportedUpdateViewModel), It.IsAny <CancellationToken>()), Times.Once); }
public async Task <ActionResult> UpdateBrowsersSupportedAsync([FromRoute][Required] string id, [FromBody][Required] UpdateSolutionBrowsersSupportedViewModel updateSolutionBrowsersSupportedViewModel) => (await _mediator.Send(new UpdateSolutionBrowsersSupportedCommand(id, updateSolutionBrowsersSupportedViewModel)).ConfigureAwait(false)).ToActionResult();