Exemplo n.º 1
0
        public async Task FetchReadme_ContentNotFound()
        {
            // Arrange
            MockRestClient(null, HttpStatusCode.NotFound);
            DataSourceAdaptee = new GitlabDataSourceAdaptee(ConfigurationMock, ClientFactoryMock.Object, Mapper);

            // Act
            Action act = () => DataSourceAdaptee.FetchReadme("https://google.nl/test");
            string retrievedReadmeContent = await DataSourceAdaptee.FetchReadme("https://google.nl/test");

            // Assert
            act.Should().NotThrow();
            retrievedReadmeContent.Should().BeNullOrEmpty();
        }
Exemplo n.º 2
0
        public async Task FetchReadme_GoodFlow()
        {
            // Arrange
            string readmeContent = new string("This is the content from a test readme file");

            MockRestClient(readmeContent, HttpStatusCode.OK);
            DataSourceAdaptee = new GitlabDataSourceAdaptee(ConfigurationMock, ClientFactoryMock.Object, Mapper);

            // Act
            Action act             = () => DataSourceAdaptee.FetchReadme("https://google.nl/test");
            string retrievedReadme = await DataSourceAdaptee.FetchReadme("https://google.nl/test");

            // Assert
            act.Should().NotThrow();
            retrievedReadme.Substring(1, retrievedReadme.Length - 2).Should().Be(readmeContent);
        }
Exemplo n.º 3
0
        public void FetchReadme_ResponseIsNotSuccessful()
        {
            // Arrange
            string errorMessage = "Invalid test request";

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

            // Act
            Func <Task> act = () => DataSourceAdaptee.FetchReadme("https://google.nl/test");

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