Exemplo n.º 1
0
        public async Task UpdateInvalidReturnsBadRequestWithValidationDetails()
        {
            resultDictionary.Add("third-party-components", "maxLength");
            resultDictionary.Add("device-capabilities", "maxLength");
            var request = new UpdateNativeDesktopThirdPartyViewModel();

            var result = await nativeDesktopThirdPartyController.UpdatedThirdParty(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["third-party-components"].Should().Be("maxLength");
            validationResult["device-capabilities"].Should().Be("maxLength");

            Expression <Func <UpdateSolutionNativeDesktopThirdPartyCommand, bool> > match = c =>
                                                                                            c.Data.ThirdPartyComponents == request.ThirdPartyComponents &&
                                                                                            c.Data.DeviceCapabilities == request.DeviceCapabilities &&
                                                                                            c.SolutionId == SolutionId;

            mediatorMock.Verify(m => m.Send(It.Is(match), It.IsAny <CancellationToken>()));
        }
Exemplo n.º 2
0
        public async Task UpdateValidThirdPartyDetails()
        {
            var request = new UpdateNativeDesktopThirdPartyViewModel
            {
                ThirdPartyComponents = "New Component",
                DeviceCapabilities   = "New Capability"
            };

            var result =
                (await _nativeDesktopThirdPartyController.UpdatedThirdParty(_solutionId, request)
                 .ConfigureAwait(false)) as NoContentResult;

            result.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
            _mediatorMock.Verify(
                x => x.Send(
                    It.Is <UpdateSolutionNativeDesktopThirdPartyCommand>(c =>
                                                                         c.SolutionId == _solutionId && c.Data.ThirdPartyComponents == "New Component" &&
                                                                         c.Data.DeviceCapabilities == "New Capability"),
                    It.IsAny <CancellationToken>()), Times.Once);
        }
Exemplo n.º 3
0
        public async Task UpdateValidThirdPartyDetails()
        {
            var request = new UpdateNativeDesktopThirdPartyViewModel
            {
                ThirdPartyComponents = "New Component",
                DeviceCapabilities   = "New Capability",
            };

            var result = await nativeDesktopThirdPartyController.UpdatedThirdParty(SolutionId, request) as NoContentResult;

            Expression <Func <UpdateSolutionNativeDesktopThirdPartyCommand, bool> > match = c =>
                                                                                            c.SolutionId == SolutionId &&
                                                                                            c.Data.ThirdPartyComponents == "New Component" &&
                                                                                            c.Data.DeviceCapabilities == "New Capability";

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

            mediatorMock.Verify(m => m.Send(It.Is(match), It.IsAny <CancellationToken>()));
        }
Exemplo n.º 4
0
        public async Task UpdateInvalidReturnsBadRequestWithValidationDetails()
        {
            _resultDictionary.Add("third-party-components", "maxLength");
            _resultDictionary.Add("device-capabilities", "maxLength");
            var request = new UpdateNativeDesktopThirdPartyViewModel();

            var result =
                (await _nativeDesktopThirdPartyController.UpdatedThirdParty(_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["third-party-components"].Should().Be("maxLength");
            validationResult["device-capabilities"].Should().Be("maxLength");

            _mediatorMock.Verify(x => x.Send(
                                     It.Is <UpdateSolutionNativeDesktopThirdPartyCommand>(c =>
                                                                                          c.Data.ThirdPartyComponents == request.ThirdPartyComponents &&
                                                                                          c.Data.DeviceCapabilities == request.DeviceCapabilities &&
                                                                                          c.SolutionId == _solutionId), It.IsAny <CancellationToken>()),
                                 Times.Once);
        }