public async Task ShouldUpdateValidationValid() { var expected = "an implementation timescales description"; var viewModel = new UpdateImplementationTimescalesViewModel { Description = expected }; var result = (await _controller.Update(SolutionId, viewModel).ConfigureAwait(false)) as NoContentResult; result.StatusCode.Should().Be((int)HttpStatusCode.NoContent); _mediatorMock.Verify(m => m.Send(It.Is <UpdateImplementationTimescalesCommand>(q => q.SolutionId == SolutionId && q.Description == expected), It.IsAny <CancellationToken>()), Times.Once); }
public async Task ShouldUpdateValidationValid() { const string expected = "an implementation timescales description"; var model = new UpdateImplementationTimescalesViewModel { Description = expected }; var result = await controller.Update(SolutionId, model) as NoContentResult; Assert.NotNull(result); result.StatusCode.Should().Be(StatusCodes.Status204NoContent); mediatorMock.Verify(m => m.Send( It.Is <UpdateImplementationTimescalesCommand>(c => c.SolutionId == SolutionId && c.Description == expected), It.IsAny <CancellationToken>())); }
public async Task ShouldUpdateValidationInvalid() { var expected = "an implementation timescales description"; var viewModel = new UpdateImplementationTimescalesViewModel { Description = expected }; _resultDictionary.Add("description", "maxLength"); var result = (await _controller.Update(SolutionId, viewModel).ConfigureAwait(false)) as BadRequestObjectResult; result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); var resultValue = result.Value as Dictionary <string, string>; resultValue.Count.Should().Be(1); resultValue["description"].Should().Be("maxLength"); _mediatorMock.Verify(m => m.Send( It.Is <UpdateImplementationTimescalesCommand>(q => q.SolutionId == SolutionId && q.Description == expected), It.IsAny <CancellationToken>()), Times.Once); }
public async Task ShouldUpdateValidationInvalid() { const string expected = "an implementation timescales description"; var viewModel = new UpdateImplementationTimescalesViewModel { Description = expected }; resultDictionary.Add("description", "maxLength"); var result = await controller.Update(SolutionId, viewModel) as BadRequestObjectResult; Assert.NotNull(result); result.StatusCode.Should().Be(StatusCodes.Status400BadRequest); var resultValue = result.Value as Dictionary <string, string>; Assert.NotNull(resultValue); resultValue.Count.Should().Be(1); resultValue["description"].Should().Be("maxLength"); mediatorMock.Verify(m => m.Send( It.Is <UpdateImplementationTimescalesCommand>(q => q.SolutionId == SolutionId && q.Description == expected), It.IsAny <CancellationToken>())); }
public async Task <ActionResult> Update([FromRoute][Required] string id, [FromBody][Required] UpdateImplementationTimescalesViewModel implementationTimescales) => (await _mediator.Send(new UpdateImplementationTimescalesCommand(id, implementationTimescales?.Description)).ConfigureAwait(false)).ToActionResult();
public async Task<ActionResult> Update([Required] string id, UpdateImplementationTimescalesViewModel model) => (await mediator.Send(new UpdateImplementationTimescalesCommand(id, model?.Description))).ToActionResult();