示例#1
0
        public async Task FetchOauthTokens_GoodFlow()
        {
            OauthTokens oauthTokens = new OauthTokens {
                AccessToken = "token"
            };

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

            // Act
            Action      act = () => DataSourceAdaptee.FetchOauthTokens(It.IsAny <string>());
            OauthTokens retrievedOauthTokens = await DataSourceAdaptee.FetchOauthTokens(It.IsAny <string>());

            // Assert
            act.Should().NotThrow();
            retrievedOauthTokens.Should().BeEquivalentTo(oauthTokens);
            retrievedOauthTokens.Should().NotBeNull();
        }
示例#2
0
        public void FetchOauthTokens_ResponseIsNotSuccessful()
        {
            // Arrange
            string errorMessage = "Invalid test request";

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

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

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