Esempio n. 1
0
        public async Task FailedConnectionDelayTest()
        {
            _nodeStats = new NodeStatsLight(_node);

            var isConnDelayed = _nodeStats.IsConnectionDelayed();

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

            _nodeStats.AddNodeStatsEvent(NodeStatsEventType.ConnectionFailed);
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsTrue(isConnDelayed.Result, "just after failure");
            Assert.AreEqual(NodeStatsEventType.ConnectionFailed, isConnDelayed.DelayReason);
            await Task.Delay(125);

            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsFalse(isConnDelayed.Result, "125ms after failure");
        }
Esempio n. 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");
        }
Esempio n. 3
0
        public void FailedConnectionDelayTest(bool useLight)
        {
            _nodeStats = useLight ? new NodeStatsLight(_node, _config) : (INodeStats) new NodeStats(_node, _config);

            var isConnDelayed = _nodeStats.IsConnectionDelayed();

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

            _nodeStats.AddNodeStatsEvent(NodeStatsEventType.ConnectionFailed);
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsTrue(isConnDelayed.Result, "just after failure");
            Assert.AreEqual(NodeStatsEventType.ConnectionFailed, isConnDelayed.DelayReason);
            var task = Task.Delay(125);

            task.Wait();
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsFalse(isConnDelayed.Result, "125ms after failure");
        }
Esempio n. 4
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");
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public (bool Result, NodeStatsEventType?DelayReason) IsConnectionDelayed(Node node)
        {
            INodeStats stats = GetOrAdd(node);

            return(stats.IsConnectionDelayed());
        }