public async Task FetchUserFromAccessToken_GoodFlow( [GitlabDataSourceUserResourceResultDataSource] GitlabDataSourceUserResourceResult userResourceResult) { // Arrange MockRestClient(userResourceResult, HttpStatusCode.OK); DataSourceAdaptee = new GitlabDataSourceAdaptee(ConfigurationMock, ClientFactoryMock.Object, Mapper); // Act Action act = () => DataSourceAdaptee.FetchUserFromAccessToken(It.IsAny <string>()); GitlabDataSourceUserResourceResult retrievedUsers = await DataSourceAdaptee.FetchUserFromAccessToken(It.IsAny <string>()); // Assert act.Should() .NotThrow(); retrievedUsers.Should() .BeEquivalentTo(userResourceResult); }
public void FetchUserFromAccessToken_ResponseIsNotSuccessful() { // Arrange string errorMessage = "Invalid test request"; MockRestClient(null, HttpStatusCode.BadRequest, errorMessage); DataSourceAdaptee = new GitlabDataSourceAdaptee(ConfigurationMock, ClientFactoryMock.Object, Mapper); // Act Func <Task> act = () => DataSourceAdaptee.FetchUserFromAccessToken(It.IsAny <string>()); // Assert act.Should() .ThrowExactly <ExternalException>() .WithMessage(errorMessage); }