public async Task AgentyTeamApi_default_client_is_disposed() { var api = new AgentyApi("api_key"); api.Dispose(); Assert.ThrowsAsync <ObjectDisposedException>(() => api.Teams.GetAllTeamMembersAsync()); }
public void AgentyApi_non_default_client_is_configured() { var client = new HttpClient(); using (var api = new AgentyApi("api_key", client)) { Assert.IsTrue(api.HttpClient.BaseAddress.OriginalString == "https://api.agenty.com/v1/", "Base Address is wrong"); Assert.IsTrue(api.HttpClient.DefaultRequestHeaders.Accept.Count() == 1, "Header count is wrong"); } }
public async Task AgentyApi_non_default_client_controls_its_lifecycle() { var client = new HttpClient { BaseAddress = new Uri("https://test.proxy.local/") }; using (var api = new AgentyApi("api_key", client)) { Assert.IsTrue(api.HttpClient.BaseAddress.OriginalString == "https://test.proxy.local/"); } try { await client.GetAsync("test"); } catch (ObjectDisposedException) { Assert.Fail("Should not have been disposed"); } catch (HttpRequestException) { // don't do anything } }
public async Task AgentyApi_is_disposed_successfully() { var api = new AgentyApi("api_key"); api.Dispose(); }