public void watchdog_should_not_disconnect_if_idle_timeout_not_reached()
        {
            var server = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, TimeSpan.FromSeconds(1));

            var connection = CreateMockedConnection(DateTime.UtcNow, TimeSpan.Zero);
            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            connection.Verify(x => x.Disconnect(), Times.Never);
        }
        public void watchdog_should_disconnect_if_idle_timeout_is_reached()
        {
            var server = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, 1);

            var connection = CreateMockedConnectionWithIdleTime(1);
            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            connection.Verify(x => x.Disconnect());
        }
Esempio n. 3
0
        public void watchdog_should_not_disconnect_if_connection_timeout_is_reached()
        {
            var server   = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, 1000);

            var connection = CreateMockedConnectionWithIdleTime(0);

            connection.Setup(x => x.Disconnect()).Throws(new Exception("RequestDisconnection shouldn't be called"));
            server.Connections.Add(connection.Object);
            watchdog.TimerCall();
        }
        public void watchdog_should_not_disconnect_if_idle_timeout_not_reached()
        {
            var server   = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, TimeSpan.FromSeconds(1));

            var connection = CreateMockedConnection(DateTime.UtcNow, TimeSpan.Zero);

            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            connection.Verify(x => x.Disconnect(), Times.Never);
        }
Esempio n. 5
0
        public void watchdog_should_disconnect_if_idle_timeout_is_reached()
        {
            var server   = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, 1);

            var connection = CreateMockedConnectionWithIdleTime(1);

            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            connection.Verify(x => x.Disconnect());
        }
        public void watchdog_should_be_able_to_Stop()
        {
            var server = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, 1);
            watchdog.Stop();

            var connection = CreateMockedConnectionWithIdleTime(1);
            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            connection.Verify(x => x.Disconnect(), Times.Never);
        }
        public void watchdog_should_fire_TerminateConnection_if_idle_timeout_is_reached()
        {
            var server = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, 1);
            bool terminatingConnection = false;
            watchdog.TerminatingConnection += (s, e) => terminatingConnection = true;

            var connection = CreateMockedConnectionWithIdleTime(1);
            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            Assert.True(terminatingConnection);
        }
        public void watchdog_should_not_disconnect_if_connection_timeout_is_not_reached()
        {
            var server   = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithConnectionTimeout(server, TimeSpan.FromSeconds(2));

            watchdog.FuncTimeSource = () => new DateTime(2000, 1, 1).AddSeconds(1);

            var connection = CreateMockedConnection(new DateTime(2000, 1, 1), TimeSpan.Zero);

            connection.Setup(x => x.Disconnect()).Throws(new Exception("RequestDisconnection shouldn't be called"));
            server.Connections.Add(connection.Object);
            watchdog.TimerCall();
        }
Esempio n. 9
0
        public void watchdog_should_be_able_to_Stop()
        {
            var server   = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, 1);

            watchdog.Stop();

            var connection = CreateMockedConnectionWithIdleTime(1);

            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            connection.Verify(x => x.Disconnect(), Times.Never);
        }
        public void watchdog_should_fire_TerminateConnection_if_idle_timeout_is_reached()
        {
            var server = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, TimeSpan.FromMilliseconds(1));
            
            var terminatingConnection = false;
            watchdog.TerminatingConnection += (s, e) => terminatingConnection = true;

            var connection = CreateMockedConnection(DateTime.UtcNow, TimeSpan.FromMilliseconds(2));
            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            Assert.True(terminatingConnection);
        }
        public void watchdog_should_disconnect_if_connection_timeout_is_reached()
        {
            var server   = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithConnectionTimeout(server, TimeSpan.FromSeconds(1));

            watchdog.FuncTimeSource = () => new DateTime(2000, 1, 1).AddSeconds(2);

            var connection = CreateMockedConnection(new DateTime(2000, 1, 1), TimeSpan.Zero);

            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            connection.Verify(x => x.Disconnect());
        }
Esempio n. 12
0
        public void watchdog_should_fire_TerminateConnection_if_idle_timeout_is_reached()
        {
            var  server   = new ServerConnectionsStub();
            var  watchdog = StartWatchdogWithIdleTimeout(server, 1);
            bool terminatingConnection = false;

            watchdog.TerminatingConnection += (s, e) => terminatingConnection = true;

            var connection = CreateMockedConnectionWithIdleTime(1);

            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            Assert.True(terminatingConnection);
        }
        public void watchdog_should_fire_TerminateConnection_if_idle_timeout_is_reached()
        {
            var server   = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, TimeSpan.FromMilliseconds(1));

            var terminatingConnection = false;

            watchdog.TerminatingConnection += (s, e) => terminatingConnection = true;

            var connection = CreateMockedConnection(DateTime.UtcNow, TimeSpan.FromMilliseconds(2));

            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            Assert.True(terminatingConnection);
        }
        public void watchdog_should_fire_TerminateConnection_if_connection_timeout_is_reached()
        {
            var server   = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithConnectionTimeout(server, TimeSpan.FromSeconds(1));

            watchdog.FuncTimeSource = () => new DateTime(2000, 1, 1).AddSeconds(2);

            var terminatingConnection = false;

            watchdog.TerminatingConnection += (s, e) => terminatingConnection = true;

            var connection = CreateMockedConnection(new DateTime(2000, 1, 1), TimeSpan.Zero);

            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            Assert.True(terminatingConnection);
        }
        public void watchdog_should_fire_TerminateConnection_if_connection_timeout_is_reached()
        {
            var server = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithConnectionTimeout(server, TimeSpan.FromSeconds(1));
            watchdog.FuncTimeSource = () => new DateTime(2000, 1, 1).AddSeconds(2);

            var terminatingConnection = false;
            watchdog.TerminatingConnection += (s, e) => terminatingConnection = true;

            var connection = CreateMockedConnection(new DateTime(2000, 1, 1), TimeSpan.Zero);
            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            Assert.True(terminatingConnection);
        }
 private static IdleConnectionDisconnectWatchdog<ServerConnectionsStub> StartWatchdogWithConnectionTimeout(ServerConnectionsStub server, TimeSpan connectionTimeout)
 {
     var watchdog = new IdleConnectionDisconnectWatchdog<ServerConnectionsStub>(server)
     {
         ConnectionTimeout = connectionTimeout,
         Interval = 1,
         IdleTimeout = new TimeSpan(-1)
     };
     watchdog.Start();
     return watchdog;
 }
        public void watchdog_should_disconnect_if_connection_timeout_is_reached()
        {
            var server = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithConnectionTimeout(server, TimeSpan.FromSeconds(1));
            watchdog.FuncTimeSource = () => new DateTime(2000, 1, 1).AddSeconds(2);

            var connection = CreateMockedConnection(new DateTime(2000, 1, 1), TimeSpan.Zero);
            server.Connections.Add(connection.Object);

            watchdog.TimerCall();
            connection.Verify(x => x.Disconnect());
        }
Esempio n. 18
0
        private static IdleConnectionDisconnectWatchdog <ServerConnectionsStub> StartWatchdogWithConnectionTimeout(ServerConnectionsStub server, long connectionTimeoutMillis)
        {
            var watchdog = new IdleConnectionDisconnectWatchdog <ServerConnectionsStub>(server)
            {
                Interval = 1,
                ConnectionTimeoutMilliseconds = connectionTimeoutMillis
            };

            watchdog.Start();
            return(watchdog);
        }
        private static IdleConnectionDisconnectWatchdog <ServerConnectionsStub> StartWatchdogWithConnectionTimeout(ServerConnectionsStub server, TimeSpan connectionTimeout)
        {
            var watchdog = new IdleConnectionDisconnectWatchdog <ServerConnectionsStub>(server)
            {
                ConnectionTimeout = connectionTimeout,
                Interval          = 1,
                IdleTimeout       = new TimeSpan(-1)
            };

            watchdog.Start();
            return(watchdog);
        }
        public void watchdog_should_not_disconnect_if_connection_timeout_is_not_reached()
        {
            var server = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithConnectionTimeout(server, TimeSpan.FromSeconds(2));
            watchdog.FuncTimeSource = () => new DateTime(2000, 1, 1).AddSeconds(1);

            var connection = CreateMockedConnection(new DateTime(2000, 1, 1), TimeSpan.Zero);
            connection.Setup(x => x.Disconnect()).Throws(new Exception("RequestDisconnection shouldn't be called"));
            server.Connections.Add(connection.Object);
            watchdog.TimerCall();
        }
 private static IdleConnectionDisconnectWatchdog<ServerConnectionsStub> StartWatchdogWithConnectionTimeout(ServerConnectionsStub server, long connectionTimeoutMillis)
 {
     var watchdog = new IdleConnectionDisconnectWatchdog<ServerConnectionsStub>(server)
     {
         Interval = 1,
         ConnectionTimeoutMilliseconds = connectionTimeoutMillis
     };
     watchdog.Start();
     return watchdog;
 }
        public void watchdog_should_not_disconnect_if_connection_timeout_is_reached()
        {
            var server = new ServerConnectionsStub();
            var watchdog = StartWatchdogWithIdleTimeout(server, 1000);

            var connection = CreateMockedConnectionWithIdleTime(0);
            connection.Setup(x => x.Disconnect()).Throws(new Exception("RequestDisconnection shouldn't be called"));
            server.Connections.Add(connection.Object);
            watchdog.TimerCall();
        }