コード例 #1
0
        public async Task FetchAllGitlabRepositories_GoodFlow(
            [GitlabDataSourceResourceResultDataSource(50)]
            IEnumerable <GitlabDataSourceResourceResult> resourceResults)
        {
            // Arrange
            MockRestClient(resourceResults, HttpStatusCode.OK);
            DataSourceAdaptee = new GitlabDataSourceAdaptee(ConfigurationMock, ClientFactoryMock.Object, Mapper);

            // Act
            Action act = () => DataSourceAdaptee.FetchAllGitlabRepositories(It.IsAny <string>(), It.IsAny <string>());
            IEnumerable <GitlabDataSourceResourceResult> retrievedResourceResults =
                await DataSourceAdaptee.FetchAllGitlabRepositories(It.IsAny <string>(), It.IsAny <string>());

            // Assert
            act.Should()
            .NotThrow();
            retrievedResourceResults.Should()
            .BeEquivalentTo(resourceResults);
        }
コード例 #2
0
        public void FetchAllGitlabRepositories_ResponseIsNotSuccessful()
        {
            // Arrange
            string errorMessage = "Invalid test request";

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

            // Act
            Func <Task> act = () => DataSourceAdaptee.FetchAllGitlabRepositories(It.IsAny <string>(), It.IsAny <string>());

            // Assert
            act.Should()
            .ThrowExactly <ExternalException>()
            .WithMessage(errorMessage);
        }