public void TestConnectionCount(ReuseTest test)
        {
            var puppy = GetPuppy.Get (test.Flags, test.TransferMode);
            var sp = ServicePointManager.FindServicePoint (puppy.Uri);
            Assert.That (sp, Is.Not.Null, "#1");
            Assert.That (sp.CurrentConnections, Is.EqualTo (1), "#2");

            sp.CloseConnectionGroup (string.Empty);
            Assert.That (sp.CurrentConnections, Is.EqualTo (0), "#3");
        }
        public void TestConnectionIdleTime(ReuseTest test)
        {
            var puppy = GetPuppy.Get (test.Flags, test.TransferMode);
            var sp = ServicePointManager.FindServicePoint (puppy.Uri);
            sp.MaxIdleTime = 2500;

            Assert.That (sp, Is.Not.Null, "#1");
            Assert.That (sp.CurrentConnections, Is.EqualTo (1), "#2");

            Thread.Sleep (2000);

            Assert.That (sp.CurrentConnections, Is.EqualTo (1), "#3");

            Thread.Sleep (600);

            Assert.That (sp.CurrentConnections, Is.EqualTo (0), "#4");
        }
        public void TestConnectionReuse(ReuseTest test)
        {
            int port = -1;
            int connections = 0;
            Debug ("TestReuse", test);
            for (int i = 0; i < test.Count; i++) {
                var puppy = GetPuppy.Get (test.Flags, test.TransferMode);
                if (puppy.RemotePort == port)
                    continue;
                if (i > 0)
                    Debug ("TestReuse - NEW CONNECTION", i, port, puppy);
                connections++;
                port = puppy.RemotePort;
                if (connections > test.Limit)
                    break;
            }

            Assert.That (connections, Is.EqualTo (1), "#1");
        }