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); }
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"); }
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"); }
public void ReportDisconnect(Node node, DisconnectType disconnectType, DisconnectReason disconnectReason) { INodeStats stats = GetOrAdd(node); stats.AddNodeStatsDisconnectEvent(disconnectType, disconnectReason); }