public void StoredMessagesCanBeRetrieved() { var topic = "askldjfdg"; var topic2 = "askldjfasdasdg"; var message1 = new object(); var message2 = new object(); var message3 = new object(); var header1 = new Dictionary <string, byte[]>(); var header2 = new Dictionary <string, byte[]>(); var header3 = new Dictionary <string, byte[]>(); var messageStore = new InMemoryMessageStore(); var index1 = messageStore.AddMessage(topic, null, header1, message1); var index2 = messageStore.AddMessage(topic2, null, header2, message2); var index3 = messageStore.AddMessage(topic, null, header3, message3); index1.Should().Be(0); index2.Should().Be(0); index3.Should().Be(1); messageStore.GetMessage(topic, 0).Should().Be(message1); messageStore.GetMessage(topic2, 0).Should().Be(message2); messageStore.GetMessage(topic, 1).Should().Be(message3); messageStore.GetMessageHeader(topic, 0).Should().BeSameAs(header1); messageStore.GetMessageHeader(topic2, 0).Should().BeSameAs(header2); messageStore.GetMessageHeader(topic, 1).Should().BeSameAs(header3); messageStore.GetMessageKey(topic, 0).Should().BeNull(); messageStore.GetMessageKey(topic2, 0).Should().BeNull(); messageStore.GetMessageKey(topic, 1).Should().BeNull(); }
public async Task MessagesInStoreAreReceived() { var topic = "askldjfdg"; var message1 = new object(); var message2 = new object(); var message3 = new object(); var header1 = new object(); var header2 = new object(); var header3 = new object(); var key1 = new object(); var key2 = new object(); var key3 = new object(); var headerList = new List <object>(); var messageList = new List <object>(); var keyList = new List <object>(); var messageStore = new InMemoryMessageStore(); var messageListener = new InMemoryMessageListener(messageStore); messageStore.AddMessage(topic, key1, header1, message1); messageStore.AddMessage(topic, key2, header2, message2); messageStore.AddMessage(topic, key3, header3, message3); await messageListener.StartAsync( new[] { topic }, async (k, h, m) => { keyList.Add(k); headerList.Add(h); messageList.Add(m); }, new CancellationTokenSource(100).Token); headerList.Should().ContainInOrder(header1, header2, header3); messageList.Should().ContainInOrder(message1, message2, message3); keyList.Should().ContainInOrder(key1, key2, key3); }