public async void EmptyConnectionGetsCollected() { var connections = new Connections(); var cnx = connections.CreateConnection(IPAddress.Loopback); using (var collector = new StaleConnectionsCollector(connections)) { await collector.CleanupExpiredHandler(); } Assert.False(connections.TryGetConnection(cnx.Id, out _)); }
public async void TimerCleansUpDocuments() { using var connections = new Connections(); var connection = connections.CreateConnection(IPAddress.Loopback); connection.CreateDocument(new MyPage(), BaseModeController.DefaultKeepAliveInterval); var required = DateTime.UtcNow.AddSeconds(10); Assert.NotEmpty(connection.GetDocuments()); await StaleConnectionsCollector.CleanupExpired(connection, required); Assert.Empty(connection.GetDocuments()); }
public async void CleanupLeavesUnexpiredDocument() { var connections = new Connections(); var cnx = connections.CreateConnection(IPAddress.Loopback); var doc1 = cnx.CreateDocument(new MyPage(), BaseModeController.DefaultKeepAliveInterval); var doc2 = cnx.CreateDocument(new MyPage(), BaseModeController.DefaultKeepAliveInterval); doc2.ModifyLastUtcForTesting(DateTime.UtcNow.AddHours(-10)); await Task.Delay(200); using (var collector = new StaleConnectionsCollector(connections)) { await collector.CleanupExpiredHandler(); } Assert.True(cnx.TryGetDocument(doc1.VirtualId, out _)); Assert.False(cnx.TryGetDocument(doc2.VirtualId, out _)); }