public async Task PingAsync_2XXResultIsConsideredHealthy(HttpStatusCode statusCode) { // Arrange var configuration = new GitLabConfiguration { BaseUrl = new Uri("https://www.foo.bar.com") }; var mockClient = new MockHttpMessageHandler(); var request = mockClient .When(HttpMethod.Get, String.Empty) .Respond(statusCode); var service = CreateService(mockClient, configuration); // Act var result = await service.PingAsync(); // Assert Assert.NotNull(result); Assert.True(result.IsSuccessful); }
public void PostConfigure_ThrowsArgumentException_OnNullBaseUrlInConfiguration( string baseUrl, string expectedInvalidValue) { // Arrange var name = nameGenerator.Next(); var configuration = new GitLabConfiguration { BaseUrl = baseUrl == null ? null : new Uri(baseUrl, UriKind.RelativeOrAbsolute) }; var verifier = new GitLabConfigurationVerifier(); // Act var exception = Record.Exception( () => verifier.PostConfigure(name, configuration) ); // Assert Assert.IsType <ArgumentException>(exception); Assert.Contains(expectedInvalidValue, exception.Message); }
private static IGitLabService CreateService( MockHttpMessageHandler mockHandler, GitLabConfiguration configuration) { if (mockHandler == null) { throw new ArgumentNullException(nameof(mockHandler)); } else if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } return(new GitLabService( mockHandler.ToHttpClient(), Options.Create <GitLabConfiguration>(configuration) )); }
public void PostConfigure_DefaultValuesAreValid() { // Arrange var name = nameGenerator.Next(); var configuration = new GitLabConfiguration(); var verifier = new GitLabConfigurationVerifier(); // Act var exception = Record.Exception( () => verifier.PostConfigure(name, configuration) ); // Assert Assert.Null(exception); }