Example #1
0
        public void ShouldBuildEvenWhenThereIsNoOptionsSet()
        {
            var simpleHttpFactory = new SimpleHttpFactory();

            simpleHttpFactory.AddClientFactory("test", _ => {});
            var client = simpleHttpFactory.GetClient("test");

            Assert.NotNull(client);
        }
Example #2
0
        public async Task ShouldBuildAHttpClientWithMessageHandlerIfAny()
        {
            var simpleHttpFactory = new SimpleHttpFactory();

            simpleHttpFactory.AddClientFactory(
                "test",
                opt => opt.MessageHandler = new TestMessageHandler()
                );
            var client = simpleHttpFactory.GetClient("test");

            var exception = await Assert.ThrowsAsync <NotImplementedException>(() => client.GetAsync("http://0.0.0.0"));

            Assert.Equal("yeah it is right", exception.Message);
        }
Example #3
0
        public void SimpleUsageTest()
        {
            var simpleHttpFactory = new SimpleHttpFactory();
            var baseAddress       = new Uri("http://0.0.0.0:9090");
            var timeout           = TimeSpan.FromMinutes(5);

            simpleHttpFactory.AddClientFactory(
                "test",
                opt => opt.ClientConfiguration = c =>
            {
                c.BaseAddress = baseAddress;
                c.Timeout     = timeout;
            }
                );
            var client = simpleHttpFactory.GetClient("test");

            Assert.Same(baseAddress, client.BaseAddress);
            Assert.Equal(timeout, client.Timeout);
        }