public void CloseConnectionTest() { var connection = GetConnection(SubscriptionType.Publisher); var watcher = new RedisWatcher(connection); watcher.Close(); Mock.Get(connection).Verify(con => con.Close(It.IsAny <bool>()), Times.Once); }
public void IgnoreSelfMessageTest() { var callback = new TaskCompletionSource <int>(); var watcher = new RedisWatcher(GetConnection(SubscriptionType.Both)); watcher.SetUpdateCallback(() => callback.TrySetResult(1)); watcher.Update(); Assert.IsFalse(callback.Task.Wait(500), "The watcher shouldn't receive its self messages"); }
public void NominalTest() { var callback = new TaskCompletionSource <int>(); var watcher = new RedisWatcher(GetConnection(SubscriptionType.Subscriber)); watcher.SetUpdateCallback(() => callback.TrySetResult(1)); var watcher2 = new RedisWatcher(GetConnection(SubscriptionType.Publisher)); watcher2.Update(); Assert.IsTrue(callback.Task.Wait(300), "The first watcher didn't receive the notification"); }