public async Task ShouldGetMobileThirdParty(string thirdPartyComponents, string deviceCapabilities)
        {
            Expression<Func<IMobileThirdParty, bool>> mobileThirdPartyInstance = m =>
                m.ThirdPartyComponents == thirdPartyComponents
                && m.DeviceCapabilities == deviceCapabilities;

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

            mockMediator
                .Setup(m => m.Send(
                    It.Is<GetClientApplicationBySolutionIdQuery>(q => q.Id == SolutionId),
                    It.IsAny<CancellationToken>()))
                .ReturnsAsync(Mock.Of(clientApplication));

            var result = await mobileThirdPartyController.GetNativeMobileThirdParty(SolutionId) as ObjectResult;

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

            var mobileThirdParty = result.Value as GetMobileThirdPartyResult;

            Assert.NotNull(mobileThirdParty);
            mobileThirdParty.ThirdPartyComponents.Should().Be(thirdPartyComponents);
            mobileThirdParty.DeviceCapabilities.Should().Be(deviceCapabilities);

            mockMediator.Verify(m => m.Send(
                It.Is<GetClientApplicationBySolutionIdQuery>(q => q.Id == SolutionId),
                It.IsAny<CancellationToken>()));
        }
Exemplo n.º 2
0
        public async Task ShouldGetMobileThirdParty(string thirdPartyComponents, string deviceCapabilities)
        {
            _mockMediator.Setup(m => m.Send(It.Is <GetClientApplicationBySolutionIdQuery>(q => q.Id == SolutionId),
                                            It.IsAny <CancellationToken>())).ReturnsAsync(Mock.Of <IClientApplication>(c =>
                                                                                                                       c.MobileThirdParty == Mock.Of <IMobileThirdParty>(m =>
                                                                                                                                                                         m.ThirdPartyComponents == thirdPartyComponents && m.DeviceCapabilities == deviceCapabilities)));

            var result = (await _mobileThirdPartyController.GetNativeMobileThirdParty(SolutionId)
                          .ConfigureAwait(false)) as ObjectResult;

            result.StatusCode.Should().Be((int)HttpStatusCode.OK);

            var mobileThirdParty = result.Value as GetMobileThirdPartyResult;

            mobileThirdParty.ThirdPartyComponents.Should().Be(thirdPartyComponents);
            mobileThirdParty.DeviceCapabilities.Should().Be(deviceCapabilities);

            _mockMediator.Verify(
                m => m.Send(It.Is <GetClientApplicationBySolutionIdQuery>(q => q.Id == SolutionId),
                            It.IsAny <CancellationToken>()), Times.Once);
        }