public async Task UpdateInvalidReturnsBadRequestWithValidationDetails()
        {
            resultDictionary.Add("minimum-memory-requirement", "required");
            resultDictionary.Add("storage-requirements-description", "maxLength");

            var request = new UpdateNativeDesktopMemoryAndStorageViewModel
            {
                MinimumMemoryRequirement       = "1 bit",
                StorageRequirementsDescription = "A description",
                MinimumCpu            = "1Hz",
                RecommendedResolution = "1000,00000,0000x1",
            };

            var result = await controller.Update(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["minimum-memory-requirement"].Should().Be("required");
            validationResult["storage-requirements-description"].Should().Be("maxLength");

            Expression <Func <UpdateNativeDesktopMemoryAndStorageCommand, bool> > match = c =>
                                                                                          c.SolutionId == SolutionId &&
                                                                                          c.Data.MinimumMemoryRequirement == request.MinimumMemoryRequirement &&
                                                                                          c.Data.StorageRequirementsDescription == request.StorageRequirementsDescription &&
                                                                                          c.Data.MinimumCpu == request.MinimumCpu &&
                                                                                          c.Data.RecommendedResolution == request.RecommendedResolution;

            mediatorMock.Verify(m => m.Send(It.Is(match), It.IsAny <CancellationToken>()));
        }
 public async Task <ActionResult> Update([FromRoute][Required] string id,
                                         [FromBody][Required] UpdateNativeDesktopMemoryAndStorageViewModel viewModel)
 {
     return((await _mediator.Send(
                 new UpdateNativeDesktopMemoryAndStorageCommand(id, viewModel))
             .ConfigureAwait(false)).ToActionResult());
 }
            public async Task UpdateInvalidReturnsBadRequestWithValidationDetails()
            {
                _resultDictionary.Add("minimum-memory-requirement", "required");
                _resultDictionary.Add("storage-requirements-description", "maxLength");

                var request = new UpdateNativeDesktopMemoryAndStorageViewModel
                {
                    MinimumMemoryRequirement       = "1 bit",
                    StorageRequirementsDescription = "A description",
                    MinimumCpu            = "1Hz",
                    RecommendedResolution = "1000,00000,0000x1"
                };

                var result =
                    (await _controller.Update(_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["minimum-memory-requirement"].Should().Be("required");
                validationResult["storage-requirements-description"].Should().Be("maxLength");

                _mediatorMock.Verify(
                    x => x.Send(
                        It.Is <UpdateNativeDesktopMemoryAndStorageCommand>(c =>
                                                                           c.SolutionId == _solutionId &&
                                                                           c.Data.MinimumMemoryRequirement == request.MinimumMemoryRequirement &&
                                                                           c.Data.StorageRequirementsDescription == request.StorageRequirementsDescription &&
                                                                           c.Data.MinimumCpu == request.MinimumCpu &&
                                                                           c.Data.RecommendedResolution == request.RecommendedResolution
                                                                           ),
                        It.IsAny <CancellationToken>()), Times.Once);
            }
            public async Task UpdateValidMemoryAndStorageDetails()
            {
                var request = new UpdateNativeDesktopMemoryAndStorageViewModel
                {
                    MinimumMemoryRequirement       = "1 bit",
                    StorageRequirementsDescription = "A description",
                    MinimumCpu            = "1Hz",
                    RecommendedResolution = "1000,00000,0000x1"
                };

                var result =
                    (await _controller.Update(_solutionId, request)
                     .ConfigureAwait(false)) as NoContentResult;

                result.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
                _mediatorMock.Verify(
                    x => x.Send(
                        It.Is <UpdateNativeDesktopMemoryAndStorageCommand>(c =>
                                                                           c.SolutionId == _solutionId &&
                                                                           c.Data.MinimumMemoryRequirement == request.MinimumMemoryRequirement &&
                                                                           c.Data.StorageRequirementsDescription == request.StorageRequirementsDescription &&
                                                                           c.Data.MinimumCpu == request.MinimumCpu &&
                                                                           c.Data.RecommendedResolution == request.RecommendedResolution
                                                                           ),
                        It.IsAny <CancellationToken>()), Times.Once);
            }
        public async Task UpdateValidMemoryAndStorageDetails()
        {
            var request = new UpdateNativeDesktopMemoryAndStorageViewModel
            {
                MinimumMemoryRequirement       = "1 bit",
                StorageRequirementsDescription = "A description",
                MinimumCpu            = "1Hz",
                RecommendedResolution = "1000,00000,0000x1",
            };

            var result = await controller.Update(SolutionId, request) as NoContentResult;

            Assert.NotNull(result);
            result.StatusCode.Should().Be(StatusCodes.Status204NoContent);

            Expression <Func <UpdateNativeDesktopMemoryAndStorageCommand, bool> > match = c =>
                                                                                          c.SolutionId == SolutionId &&
                                                                                          c.Data.MinimumMemoryRequirement == request.MinimumMemoryRequirement &&
                                                                                          c.Data.StorageRequirementsDescription == request.StorageRequirementsDescription &&
                                                                                          c.Data.MinimumCpu == request.MinimumCpu &&
                                                                                          c.Data.RecommendedResolution == request.RecommendedResolution;

            mediatorMock.Verify(m => m.Send(It.Is(match), It.IsAny <CancellationToken>()));
        }
Exemplo n.º 6
0
 public async Task <ActionResult> Update(
     [Required] string id,
     UpdateNativeDesktopMemoryAndStorageViewModel model)
 {
     return((await mediator.Send(new UpdateNativeDesktopMemoryAndStorageCommand(id, model))).ToActionResult());
 }