Пример #1
0
        public void FetchContributorsFromRepository_ResponseIsNotSuccessful()
        {
            // Arrange
            string errorMessage = "Invalid test request";

            MockRestClient(null, HttpStatusCode.BadRequest, errorMessage);
            DataSourceAdaptee = new GitlabDataSourceAdaptee(ConfigurationMock, ClientFactoryMock.Object, Mapper);

            // Act
            Func <Task> act = () => DataSourceAdaptee.FetchContributorsFromRepository(It.IsAny <int>());

            // Assert
            act.Should().ThrowExactly <ExternalException>().WithMessage(errorMessage);
        }
Пример #2
0
        public async Task FetchContributorsFromRepository_GoodFlow(
            [GitLabDataSourceContributorResourceResultDataSource(30)] List <GitLabDataSourceContributorResourceResult> resourceResults)
        {
            MockRestClient(resourceResults, HttpStatusCode.OK);
            DataSourceAdaptee = new GitlabDataSourceAdaptee(ConfigurationMock, ClientFactoryMock.Object, Mapper);

            // Act
            Action act = () => DataSourceAdaptee.FetchContributorsFromRepository(It.IsAny <int>());
            List <GitLabDataSourceContributorResourceResult> retrievedOauthTokens = await DataSourceAdaptee.FetchContributorsFromRepository(It.IsAny <int>());

            // Assert
            act.Should().NotThrow();
            retrievedOauthTokens.Should().BeEquivalentTo(resourceResults);
            retrievedOauthTokens.Should().NotBeNull();
        }