Exemple #1
0
        public void DisconnectDelayTest()
        {
            var isConnDelayed = _nodeStats.IsConnectionDelayed();

            Assert.IsFalse(isConnDelayed.Result);

            _nodeStats.AddNodeStatsDisconnectEvent(DisconnectType.Remote, DisconnectReason.Other);
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsTrue(isConnDelayed.Result);
            Assert.AreEqual(NodeStatsEventType.Disconnect, isConnDelayed.DelayReason);
            var task = Task.Delay(100);

            task.Wait();
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsFalse(isConnDelayed.Result);
        }
Exemple #2
0
        public async Task DisconnectDelayTest()
        {
            _nodeStats = new NodeStatsLight(_node);

            var isConnDelayed = _nodeStats.IsConnectionDelayed();

            Assert.IsFalse(isConnDelayed.Result, "before disconnect");

            _nodeStats.AddNodeStatsDisconnectEvent(DisconnectType.Remote, DisconnectReason.Other);
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsTrue(isConnDelayed.Result, "just after disconnect");
            Assert.AreEqual(NodeStatsEventType.Disconnect, isConnDelayed.DelayReason);
            await Task.Delay(125);

            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsFalse(isConnDelayed.Result, "125ms after disconnect");
        }
Exemple #3
0
        public void DisconnectDelayTest(bool useLight)
        {
            _nodeStats = useLight ?  new NodeStatsLight(_node, _config) : (INodeStats) new NodeStats(_node, _config);

            var isConnDelayed = _nodeStats.IsConnectionDelayed();

            Assert.IsFalse(isConnDelayed.Result, "before disconnect");

            _nodeStats.AddNodeStatsDisconnectEvent(DisconnectType.Remote, DisconnectReason.Other);
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsTrue(isConnDelayed.Result, "just after disconnect");
            Assert.AreEqual(NodeStatsEventType.Disconnect, isConnDelayed.DelayReason);
            var task = Task.Delay(125);

            task.Wait();
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsFalse(isConnDelayed.Result, "125ms after disconnect");
        }
Exemple #4
0
        public void ReportDisconnect(Node node, DisconnectType disconnectType, DisconnectReason disconnectReason)
        {
            INodeStats stats = GetOrAdd(node);

            stats.AddNodeStatsDisconnectEvent(disconnectType, disconnectReason);
        }