public async Task ShouldGetIntegrations(string url)
        {
            mediatorMock
            .Setup(m => m.Send(
                       It.Is <GetIntegrationsBySolutionIdQuery>(q => q.Id == SolutionId),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(Mock.Of <IIntegrations>(i => i.Url == url));

            var result = await controller.Get(SolutionId);

            result.Should().BeOfType <OkObjectResult>();
            result.Should().NotBeNull();

            var objectResult = result as OkObjectResult;

            Assert.NotNull(objectResult);
            objectResult.Value.Should().BeOfType <IntegrationsResult>();

            var integrationsResult = objectResult.Value as IntegrationsResult;

            Assert.NotNull(integrationsResult);
            integrationsResult.Url.Should().Be(url);

            mediatorMock.Verify(m => m.Send(
                                    It.Is <GetIntegrationsBySolutionIdQuery>(q => q.Id == SolutionId),
                                    It.IsAny <CancellationToken>()));

            mediatorMock.VerifyNoOtherCalls();
        }
Пример #2
0
        public async Task ShouldGetIntegrations(string url)
        {
            _mediatorMock.Setup(m => m.Send(It.Is <GetIntegrationsBySolutionIdQuery>(r => r.Id == SolutionId), It.IsAny <CancellationToken>()))
            .ReturnsAsync(Mock.Of <IIntegrations>(m => m.Url == url));

            var result = await _controller.Get(SolutionId).ConfigureAwait(false);

            result.Should().BeOfType <OkObjectResult>();
            result.Should().NotBeNull();

            var objectResult = result as OkObjectResult;

            objectResult.Value.Should().BeOfType <IntegrationsResult>();

            var integrationsResult = objectResult.Value as IntegrationsResult;

            integrationsResult.Should().NotBeNull();
            integrationsResult.Url.Should().Be(url);

            _mediatorMock.Verify(m => m.Send(It.Is <GetIntegrationsBySolutionIdQuery>(r => r.Id == SolutionId), It.IsAny <CancellationToken>()), Times.Once);
            _mediatorMock.VerifyNoOtherCalls();
        }