Пример #1
0
        public async Task FetchGitlabRepositoryById_GoodFlow(
            [GitlabDataSourceResourceResultDataSource]
            GitlabDataSourceResourceResult resourceResult)
        {
            // Arrange
            MockRestClient(resourceResult, HttpStatusCode.OK);
            DataSourceAdaptee = new GitlabDataSourceAdaptee(ConfigurationMock, ClientFactoryMock.Object, Mapper);

            // Act
            Action act = () => DataSourceAdaptee.FetchGitlabRepositoryById(It.IsAny <string>(), It.IsAny <string>());
            GitlabDataSourceResourceResult retrievedResourceResult =
                await DataSourceAdaptee.FetchGitlabRepositoryById(It.IsAny <string>(), It.IsAny <string>());

            // Assert
            act.Should()
            .NotThrow();
            retrievedResourceResult.Should()
            .BeEquivalentTo(resourceResult);
        }
Пример #2
0
        public void FetchGitlabRepositoryById_ResponseIsNotSuccessful()
        {
            // Arrange
            string errorMessage = "Invalid test request";

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

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

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