public void RequestUrlCombinedCorrectlyWithoutSlashInBase() { //arrange var config = new ServerConfig(new Uri("http://localhost"), Guid.NewGuid().ToString()); var httpClient = Substitute.For <HttpClient>(); //act var agent = new StubAgent(config, httpClient); //assert Assert.Equal("http://localhost/requests", agent.RequestUrl.AbsoluteUri); }
public void HttpClientIsDisposedOnDispose() { //arrange var config = new ServerConfig(new Uri("http://localhost/"), Guid.NewGuid().ToString()); var httpClient = Substitute.For <HttpClient>(); var agent = new StubAgent(config, httpClient); //act agent.Dispose(); //assert httpClient.ReceivedWithAnyArgs().Dispose(); }
public void APIKeyAddedToAuthHeader() { //arrange var apiKey = Guid.NewGuid(); var config = new ServerConfig(new Uri("http://localhost/"), apiKey.ToString()); var httpClient = Substitute.For <HttpClient>(); //act var agent = new StubAgent(config, httpClient); //assert var base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(apiKey.ToString())); Assert.Contains(base64, agent.HttpClient.DefaultRequestHeaders.Authorization?.ToString() ?? string.Empty); }