public void SubscribeToOneChannel() { string channel = RedisSubscriptionUnitTests.GetUniqueTestChannel(); this.Subscription.SubscribeToChannels(this.subscribeTimeout, channel); Assert.AreEqual(1, this.Subscription.ActiveChannels.Count()); Assert.IsTrue(this.Subscription.ActiveChannels.Contains(channel)); }
public void UnsubscribeFromOneChannel() { string channel = RedisSubscriptionUnitTests.GetUniqueTestChannel(); this.Subscription.SubscribeToChannels(this.subscribeTimeout, channel); Assert.IsTrue(this.Subscription.UnsubscribeFromChannels(this.subscribeTimeout, channel)); Assert.IsFalse(this.Subscription.ActiveChannels.Contains(channel)); }
public void UnsubscribeFromTwoChannels() { string channel1 = RedisSubscriptionUnitTests.GetUniqueTestChannel(); string channel2 = RedisSubscriptionUnitTests.GetUniqueTestChannel(); this.Subscription.SubscribeToChannels(this.subscribeTimeout, channel1, channel2); Assert.IsTrue(this.Subscription.UnsubscribeFromChannels(this.subscribeTimeout, channel1, channel2)); Assert.AreEqual(0, this.Subscription.ActiveChannels.Count()); }
public void DoNotReceiveMessageIfNotSubscribedForChannel() { string channel1 = RedisSubscriptionUnitTests.GetUniqueTestChannel(); string channel2 = RedisSubscriptionUnitTests.GetUniqueTestChannel(); this.Subscription.SubscribeToChannels(TimeSpan.FromSeconds(1), channel1); Helpers.WaitForEvent <RedisMessageEventArgs>( TimeSpan.FromSeconds(1), handler => this.Subscription.MessageReceived += handler, () => this.PublishMessage(channel2, "Hello")); }
public void DoNotReceiveMessageAfterUnsubscribeFromChannel() { string channel = RedisSubscriptionUnitTests.GetUniqueTestChannel(); this.Subscription.SubscribeToChannels(this.subscribeTimeout, channel); Assert.IsTrue(this.Subscription.UnsubscribeFromChannels(this.subscribeTimeout, channel)); Helpers.WaitForEvent <RedisMessageEventArgs>( TimeSpan.FromSeconds(1), handler => this.Subscription.MessageReceived += handler, () => this.PublishMessage(channel, "Hello")); }
public void ReceiveMessageForSubscribedChannel() { string channel1 = RedisSubscriptionUnitTests.GetUniqueTestChannel(); this.Subscription.SubscribeToChannels(this.subscribeTimeout, channel1); Assert.AreEqual(1, this.Subscription.ActiveChannels.Count()); Assert.IsTrue(this.Subscription.ActiveChannels.Contains(channel1)); RedisMessageEventArgs args = Helpers.WaitForEvent <RedisMessageEventArgs>( TimeSpan.FromSeconds(1), handler => this.Subscription.MessageReceived += handler, () => this.PublishMessage(channel1, "Hello")); Assert.AreEqual(channel1, args.Channel); Assert.AreEqual("Hello", args.Message); }
public void SubscribeToChannelsTimeout() { string channel = RedisSubscriptionUnitTests.GetUniqueTestChannel(); this.Subscription.SubscribeToChannels(TimeSpan.FromTicks(1), channel); }