public async Task ShouldUpdateValidationValid() { var viewModel = new UpdateSolutionMemoryAndStorageRequest(); var validationModel = new RequiredMaxLengthResult(); _mockMediator .Setup(m => m.Send( It.Is <UpdateSolutionMobileMemoryStorageCommand>(q => q.Id == SolutionId && q.MinimumMemoryRequirement == viewModel.MinimumMemoryRequirement && q.Description == viewModel.Description), It.IsAny <CancellationToken>())) .ReturnsAsync(validationModel); var result = (await _memoryAndStorageController.UpdateMemoryAndStorageAsync(SolutionId, viewModel) .ConfigureAwait(false)) as NoContentResult; result?.StatusCode.Should().Be((int)HttpStatusCode.NoContent); _mockMediator.Verify( m => m.Send( It.Is <UpdateSolutionMobileMemoryStorageCommand>(q => q.Id == SolutionId && q.MinimumMemoryRequirement == viewModel.MinimumMemoryRequirement && q.Description == viewModel.Description), It.IsAny <CancellationToken>()), Times.Once); }
public async Task ShouldUpdateValidationValid() { var model = new UpdateSolutionMemoryAndStorageRequest(); var validationModel = new Mock <ISimpleResult>(); validationModel.Setup(s => s.IsValid).Returns(true); Expression <Func <UpdateSolutionMobileMemoryStorageCommand, bool> > match = c => c.Id == SolutionId && c.MinimumMemoryRequirement == model.MinimumMemoryRequirement && c.Description == model.Description; mockMediator .Setup(m => m.Send(It.Is(match), It.IsAny <CancellationToken>())) .ReturnsAsync(validationModel.Object); var result = await memoryAndStorageController.UpdateMemoryAndStorageAsync( SolutionId, model) as NoContentResult; Assert.NotNull(result); result.StatusCode.Should().Be(StatusCodes.Status204NoContent); mockMediator.Verify(m => m.Send(It.Is(match), It.IsAny <CancellationToken>())); }