public void Should_be_able_to_use_callback_to_register_client() { var provider = new HttpClientProvider(); provider.Add("my-name", () => new HttpClient()); var client = provider.Get("my-name"); Assert.That(client, Is.Not.Null); }
public void Should_get_the_same_named_instance() { var provider = new HttpClientProvider(); provider.Add("my-name", new HttpClient()); var client1 = provider.Get("my-name"); var client2 = provider.Get("my-name"); Assert.That(client1, Is.SameAs(client2)); }
public void Should_be_able_to_use_callback_to_configure_client() { var provider = new HttpClientProvider(); var baseAddress = new Uri("https://my-api/"); provider.Add("my-name", httpClient => { httpClient.BaseAddress = baseAddress; }); var client = provider.Get("my-name"); Assert.That(client, Is.Not.Null); Assert.That(client.BaseAddress, Is.SameAs(baseAddress)); }