public async Task UpdateInvalidReturnsBadRequestWithValidationDetails() { _resultDictionary.Add("summary", "maxLength"); _resultDictionary.Add("link", "maxLength"); var request = new UpdatePublicCloudViewModel(); var result = (await _publicCloudHostingController.UpdatePublicCloudHosting(_solutionId, request) .ConfigureAwait(false)) as BadRequestObjectResult; result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); var validationResult = result.Value as Dictionary <string, string>; validationResult.Count.Should().Be(2); validationResult["summary"].Should().Be("maxLength"); validationResult["link"].Should().Be("maxLength"); _mediatorMock.Verify(x => x.Send( It.Is <UpdatePublicCloudCommand>(c => c.Data.Summary == request.Summary && c.Data.Link == request.Link && c.Data.RequiresHSCN == request.RequiresHSCN && c.SolutionId == _solutionId), It.IsAny <CancellationToken>()), Times.Once); }
public async Task UpdateInvalidReturnsBadRequestWithValidationDetails() { resultDictionary.Add("summary", "maxLength"); resultDictionary.Add("link", "maxLength"); var request = new UpdatePublicCloudViewModel(); var result = await publicCloudHostingController.UpdatePublicCloudHosting(SolutionId, request) as BadRequestObjectResult; Assert.NotNull(result); result.StatusCode.Should().Be(StatusCodes.Status400BadRequest); var validationResult = result.Value as Dictionary <string, string>; Assert.NotNull(validationResult); validationResult.Count.Should().Be(2); validationResult["summary"].Should().Be("maxLength"); validationResult["link"].Should().Be("maxLength"); Expression <Func <UpdatePublicCloudCommand, bool> > match = c => c.Data.Summary == request.Summary && c.Data.Link == request.Link && c.Data.RequiresHscn == request.RequiresHscn && c.SolutionId == SolutionId; mediatorMock.Verify(m => m.Send(It.Is(match), It.IsAny <CancellationToken>())); }
public async Task UpdateValidPublicCloud() { var request = new UpdatePublicCloudViewModel { Summary = "New Summary", Link = "New URL", RequiresHscnArray = new HashSet <string> { "New requires HSCN" }, }; var result = await publicCloudHostingController.UpdatePublicCloudHosting(SolutionId, request) as NoContentResult; Assert.NotNull(result); result.StatusCode.Should().Be(StatusCodes.Status204NoContent); mediatorMock.Verify(m => m.Send( It.Is <UpdatePublicCloudCommand>(c => c.SolutionId == SolutionId && c.Data == request), It.IsAny <CancellationToken>())); }
public async Task UpdateValidPublicCloud() { var request = new UpdatePublicCloudViewModel() { Summary = "New Summary", Link = "New URL", RequiresHSCNArray = new HashSet <string> { "New requires HSCN" } }; var result = (await _publicCloudHostingController.UpdatePublicCloudHosting(_solutionId, request) .ConfigureAwait(false)) as NoContentResult; result.StatusCode.Should().Be((int)HttpStatusCode.NoContent); _mediatorMock.Verify( x => x.Send( It.Is <UpdatePublicCloudCommand>(c => c.SolutionId == _solutionId && c.Data == request), It.IsAny <CancellationToken>()), Times.Once); }
public async Task <ActionResult> UpdatePublicCloudHosting([Required] string id, UpdatePublicCloudViewModel model) => (await mediator.Send(new UpdatePublicCloudCommand(id, model))).ToActionResult();
public async Task <ActionResult> UpdatePublicCloudHosting([FromRoute][Required] string id, [FromBody][Required] UpdatePublicCloudViewModel viewModel) => (await _mediator.Send(new UpdatePublicCloudCommand(id, viewModel)).ConfigureAwait(false)).ToActionResult();