コード例 #1
0
        public void SendMessageDoesNothingOnEmptyDictionary()
        {
            // Arrange
            Mock <TestBusContext> context = new Mock <TestBusContext>(MockBehavior.Strict);
            var dictionary = new Dictionary <TestBusKey, TestBusQueueWrapper <EventMessage> >();

            context.SetupGet(e => e.DataQueues)
            .Returns(dictionary);

            var sender = new TestMessageSender(context.Object);

            var message = new EventMessage {
                Topic = "UnknownTopic"
            };

            // Act
            sender.SendMessage(message);

            // Assert
            Assert.AreEqual(0, dictionary.Count);
        }
コード例 #2
0
        public void SendMessageDoesNothingWithoutAvailableQueue(string topic)
        {
            Mock <TestBusContext> context = new Mock <TestBusContext>(MockBehavior.Strict);
            var dictionary = new Dictionary <TestBusKey, TestBusQueueWrapper <EventMessage> >();

            context.SetupGet(e => e.DataQueues)
            .Returns(dictionary);

            var sender = new TestMessageSender(context.Object);

            var message = new EventMessage {
                Topic = "UnknownTopic"
            };

            // Act
            sender.SendMessage(message);

            // Assert
            var key = new TestBusKey("testQueue", topic);

            Assert.IsFalse(dictionary.ContainsKey(key));
        }
コード例 #3
0
        public void TopicsAreSelectedByRegex(string regexTopic, string topic)
        {
            Mock <TestBusContext> context = new Mock <TestBusContext>(MockBehavior.Strict);
            var dictionary = new Dictionary <TestBusKey, TestBusQueueWrapper <EventMessage> >();
            var key        = new TestBusKey("testQueue", topic);

            dictionary[key] = new TestBusQueueWrapper <EventMessage>();

            context.SetupGet(e => e.DataQueues)
            .Returns(dictionary);

            var sender  = new TestMessageSender(context.Object);
            var message = new EventMessage {
                Topic = topic
            };

            // Act
            sender.SendMessage(message);

            // Assert
            Assert.IsTrue(dictionary.ContainsKey(key));
        }
コード例 #4
0
        public void SendMessageAddsMessageToQueueIfQueueExists(string topic)
        {
            Mock <TestBusContext> context = new Mock <TestBusContext>(MockBehavior.Strict);
            var dictionary = new Dictionary <TestBusKey, TestBusQueueWrapper <EventMessage> >();
            var key        = new TestBusKey("testQueue", topic);

            dictionary[key] = new TestBusQueueWrapper <EventMessage>();

            context.SetupGet(e => e.DataQueues)
            .Returns(dictionary);

            var sender = new TestMessageSender(context.Object);

            var message = new EventMessage {
                Topic = topic
            };

            // Act
            sender.SendMessage(message);

            // Assert
            Assert.IsTrue(dictionary.ContainsKey(key));
            Assert.AreEqual(1, dictionary[key].Queue.Count);
        }