public async Task ShouldUpdateValidationInvalid() { var viewModel = new UpdateSolutionMemoryAndStorageRequest(); var validationModel = new RequiredMaxLengthResult() { Required = { "minimum-memory-requirement", "storage-requirements-description" }, MaxLength = { "storage-requirements-description" } }; _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 BadRequestObjectResult; result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); (result.Value as UpdateFormRequiredMaxLengthResult).Required.Should().BeEquivalentTo(new[] { "minimum-memory-requirement", "storage-requirements-description" }); (result.Value as UpdateFormRequiredMaxLengthResult).MaxLength.Should().BeEquivalentTo(new[] { "storage-requirements-description" }); _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 ShouldUpdateValidationInvalid() { var solutionSummaryUpdateViewModel = new UpdateSolutionSummaryViewModel() { Summary = string.Empty }; var validationModel = new RequiredMaxLengthResult() { Required = { "summary" }, MaxLength = { "summary", "description", "link" } }; _mockMediator.Setup(m => m.Send(It.Is <UpdateSolutionSummaryCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionSummaryViewModel == solutionSummaryUpdateViewModel), It.IsAny <CancellationToken>())).ReturnsAsync(validationModel); var result = (await _solutionDescriptionController.UpdateAsync(SolutionId, solutionSummaryUpdateViewModel).ConfigureAwait(false)) as BadRequestObjectResult; result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); var resultValue = result.Value as UpdateFormRequiredMaxLengthResult; resultValue.Required.Should().BeEquivalentTo(new[] { "summary" }); resultValue.MaxLength.Should().BeEquivalentTo(new[] { "summary", "description", "link" }); _mockMediator.Verify(m => m.Send(It.Is <UpdateSolutionSummaryCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionSummaryViewModel == solutionSummaryUpdateViewModel), It.IsAny <CancellationToken>()), Times.Once); }
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 ShouldUpdateValidationInvalid() { var viewModel = new UpdateSolutionMobileOperatingSystemsViewModel(); var validationModel = new RequiredMaxLengthResult() { Required = { "operating-systems" }, MaxLength = { "operating-systems-description" } }; _mockMediator.Setup(m => m.Send( It.Is <UpdateSolutionMobileOperatingSystemsCommand>(q => q.Id == SolutionId && q.ViewModel == viewModel), It.IsAny <CancellationToken>())).ReturnsAsync(validationModel); var result = (await _mobileOperatingSystemsController.UpdateMobileOperatingSystems(SolutionId, viewModel).ConfigureAwait(false)) as BadRequestObjectResult; result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); (result.Value as UpdateFormRequiredMaxLengthResult).Required.Should().BeEquivalentTo(new[] { "operating-systems" }); (result.Value as UpdateFormRequiredMaxLengthResult).MaxLength.Should().BeEquivalentTo(new[] { "operating-systems-description" }); _mockMediator.Verify( m => m.Send( It.Is <UpdateSolutionMobileOperatingSystemsCommand>(q => q.Id == SolutionId && q.ViewModel == viewModel), It.IsAny <CancellationToken>()), Times.Once); }
public async Task ShouldUpdateValidationInvalid() { var pluginsViewModel = new UpdateSolutionPluginsViewModel(); var validationModel = new RequiredMaxLengthResult() { Required = { "plugins-required" }, MaxLength = { "plugins-detail" } }; _mockMediator.Setup(m => m.Send( It.Is <UpdateSolutionPluginsCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionPluginsViewModel == pluginsViewModel), It.IsAny <CancellationToken>())).ReturnsAsync(validationModel); var result = (await _plugInsController.UpdatePlugInsAsync(SolutionId, pluginsViewModel).ConfigureAwait(false)) as BadRequestObjectResult; result.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); (result.Value as UpdateFormRequiredMaxLengthResult).Required.Should().BeEquivalentTo(new[] { "plugins-required" }); (result.Value as UpdateFormRequiredMaxLengthResult).MaxLength.Should().BeEquivalentTo(new[] { "plugins-detail" }); _mockMediator.Verify( m => m.Send( It.Is <UpdateSolutionPluginsCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionPluginsViewModel == pluginsViewModel), It.IsAny <CancellationToken>()), Times.Once); }
public async Task ShouldUpdateValidationValid() { var solutionSummaryUpdateViewModel = new UpdateSolutionSummaryViewModel { Summary = "Summary" }; var validationModel = new RequiredMaxLengthResult(); _mockMediator.Setup(m => m.Send(It.Is <UpdateSolutionSummaryCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionSummaryViewModel == solutionSummaryUpdateViewModel), It.IsAny <CancellationToken>())).ReturnsAsync(validationModel); var result = (await _solutionDescriptionController.UpdateAsync(SolutionId, solutionSummaryUpdateViewModel).ConfigureAwait(false)) as NoContentResult; result.StatusCode.Should().Be((int)HttpStatusCode.NoContent); _mockMediator.Verify(m => m.Send(It.Is <UpdateSolutionSummaryCommand>(q => q.SolutionId == SolutionId && q.UpdateSolutionSummaryViewModel == solutionSummaryUpdateViewModel), It.IsAny <CancellationToken>()), Times.Once); }
public async Task ShouldUpdateValidationValid() { var viewModel = new UpdateSolutionMobileOperatingSystemsViewModel(); var validationModel = new RequiredMaxLengthResult(); _mockMediator .Setup(m => m.Send( It.Is <UpdateSolutionMobileOperatingSystemsCommand>(q => q.Id == SolutionId && q.ViewModel == viewModel), It.IsAny <CancellationToken>())) .ReturnsAsync(validationModel); var result = (await _mobileOperatingSystemsController.UpdateMobileOperatingSystems(SolutionId, viewModel) .ConfigureAwait(false)) as NoContentResult; result?.StatusCode.Should().Be((int)HttpStatusCode.NoContent); _mockMediator.Verify( m => m.Send( It.Is <UpdateSolutionMobileOperatingSystemsCommand>(q => q.Id == SolutionId && q.ViewModel == viewModel), It.IsAny <CancellationToken>()), Times.Once); }
internal static ActionResult ToActionResult(this RequiredMaxLengthResult validationResult) => validationResult.IsValid ? (ActionResult) new NoContentResult() : new BadRequestObjectResult(new UpdateFormRequiredMaxLengthResult(validationResult));
internal UpdateFormRequiredMaxLengthResult(RequiredMaxLengthResult validationResult) { Required = validationResult?.Required; MaxLength = validationResult?.MaxLength; }