Beispiel #1
0
        public void per_host_factory_provides_same_client_per_host()
        {
            var fac  = new PerHostFlurlClientFactory();
            var cli1 = fac.Get("http://api.com/foo");
            var cli2 = fac.Get("https://api.com/bar");

            Assert.AreSame(cli1, cli2);
        }
Beispiel #2
0
        public void can_configure_client_from_factory()
        {
            var fac = new PerHostFlurlClientFactory()
                      .ConfigureClient("http://api.com/foo", c => c.Settings.Timeout = TimeSpan.FromSeconds(123));

            Assert.AreEqual(TimeSpan.FromSeconds(123), fac.Get("https://api.com/bar").Settings.Timeout);
            Assert.AreNotEqual(TimeSpan.FromSeconds(123), fac.Get("http://api2.com/foo").Settings.Timeout);
        }
Beispiel #3
0
        public void can_configure_client_from_factory()
        {
            var fac = new PerHostFlurlClientFactory()
                      .ConfigureClient("http://api.com/foo", c => c.Settings.CookiesEnabled = true);

            Assert.IsTrue(fac.Get("https://api.com/bar").Settings.CookiesEnabled);
            Assert.IsFalse(fac.Get("http://api2.com/foo").Settings.CookiesEnabled);
        }