public void GetMessagesWhenChannelNotInitialized() { // arrange var connectionMultiplexer = _redis.GetConnection(); var database = connectionMultiplexer.GetDatabase(); database.KeyDelete("ch:{test-channel}:id"); // ensure key is not in Redis to simulate not-initialized channel // act var loader = new MessageLoader(connectionMultiplexer); var messages = loader.GetMessages("test-channel", 1, 30) .ToList(); // assert Assert.Empty(messages); }
public void GetSavedMessages() { // arrange var connectionMultiplexer = _redis.GetConnection(); var publisher = new ReliablePublisher(connectionMultiplexer); var loader = new MessageLoader(connectionMultiplexer); // act const string channelName = "test-channel-" + nameof(GetSavedMessages); publisher.Publish(channelName, "message1"); publisher.Publish(channelName, "message2"); var savedMessages = loader.GetMessages(channelName, 0) .ToList(); // assert Assert.Equal(2, savedMessages.Count); }
public void GetMessages() { // arrange var connectionMultiplexer = _redis.GetConnection(); var database = connectionMultiplexer.GetDatabase(); database.StringSet("ch:{test-channel}:id", 123); database.StringSet("ch:{test-channel}:1", DateTime.Now.Ticks); database.StringSet("ch:{test-channel}:3", DateTime.Now.Ticks); // act var loader = new MessageLoader(connectionMultiplexer); var messages = loader.GetMessages("test-channel", 1, 30) .ToList(); // assert Assert.Equal(2, messages.Count); Assert.All(messages, message => Assert.NotNull(message.Content)); }