Пример #1
0
        public async Task PopulatedThirdPartyShouldReturnCorrectThirdParty(string components, string capabilities)
        {
            Expression <Func <INativeDesktopThirdParty, bool> > nativeDesktopThirdParty = t =>
                                                                                          t.ThirdPartyComponents == components &&
                                                                                          t.DeviceCapabilities == capabilities;

            Expression <Func <IClientApplication, bool> > clientApplication = c =>
                                                                              c.NativeDesktopThirdParty == Mock.Of(nativeDesktopThirdParty);

            Expression <Func <GetClientApplicationBySolutionIdQuery, bool> > match = q => q.Id == SolutionId;

            mediatorMock
            .Setup(m => m.Send(It.Is(match), It.IsAny <CancellationToken>()))
            .ReturnsAsync(Mock.Of(clientApplication));

            var result = await nativeDesktopThirdPartyController.GetThirdParty(SolutionId) as ObjectResult;

            Assert.NotNull(result);
            result.StatusCode.Should().Be(StatusCodes.Status200OK);
            result.Value.Should().BeOfType <GetNativeDesktopThirdPartyResult>();

            var thirdPartyResult = result.Value as GetNativeDesktopThirdPartyResult;

            Assert.NotNull(thirdPartyResult);
            thirdPartyResult.ThirdPartyComponents.Should().Be(components);
            thirdPartyResult.DeviceCapabilities.Should().Be(capabilities);
        }
Пример #2
0
        public async Task PopulatedThirdPartyShouldReturnCorrectThirdParty(string components, string capabilities)
        {
            _mediatorMock.Setup(x => x.Send(It.Is <GetClientApplicationBySolutionIdQuery>(q => q.Id == _solutionId),
                                            It.IsAny <CancellationToken>()))
            .ReturnsAsync(Mock.Of <IClientApplication>(c =>
                                                       c.NativeDesktopThirdParty == Mock.Of <INativeDesktopThirdParty>(t =>
                                                                                                                       t.ThirdPartyComponents == components && t.DeviceCapabilities == capabilities)));

            var result = await _nativeDesktopThirdPartyController.GetThirdParty(_solutionId).ConfigureAwait(false) as ObjectResult;

            result.Should().NotBeNull();
            result.StatusCode.Should().Be((int)HttpStatusCode.OK);
            result.Value.Should().BeOfType <GetNativeDesktopThirdPartyResult>();
            var thirdPartyResult = result.Value as GetNativeDesktopThirdPartyResult;

            thirdPartyResult.ThirdPartyComponents.Should().Be(components);
            thirdPartyResult.DeviceCapabilities.Should().Be(capabilities);
        }