Esempio n. 1
0
        public async Task WhenMessageIsPublished_ThenMessagePublishedEventsAreFired()
        {
            var broker = new MockBrokerServiceWithEvents(MockStatefulServiceContextFactory.Default, new MockReliableStateManager());
            await broker.PublishMessageAsync(new TestMessage().CreateMessageWrapper());

            // Note: This message has no subscribers
            Assert.AreEqual(1, broker.MessagePublishedEventCount);
            Assert.AreEqual(0, broker.MessageQueuedToSubscriberEventCount);
        }
Esempio n. 2
0
        public async Task WhenMessageIsPublished_ThenMessageQueuedToSubscriberEventsAreFiredForEachSubscriber()
        {
            var broker = new MockBrokerServiceWithEvents(MockStatefulServiceContextFactory.Default, new MockReliableStateManager());
            await broker.SubscribeAsync(GetMockReferenceWrapper("Subscriber1"), typeof(TestMessage).FullName);

            await broker.SubscribeAsync(GetMockReferenceWrapper("Subscriber2"), typeof(TestMessage).FullName);

            await broker.PublishMessageAsync(new TestMessage().CreateMessageWrapper());

            Assert.AreEqual(1, broker.MessagePublishedEventCount);
            Assert.AreEqual(2, broker.MessageQueuedToSubscriberEventCount);
        }
Esempio n. 3
0
        public async Task WhenMessageDeliveryFails_ThenMessageDeliveryFailedEventsAreFired()
        {
            var broker = new MockBrokerServiceWithEvents(MockStatefulServiceContextFactory.Default, new MockReliableStateManager());
            await broker.SubscribeAsync(GetMockReferenceWrapper("Subscriber1"), typeof(TestMessage).FullName);

            await broker.SubscribeAsync(GetMockReferenceWrapper("Subscriber2", true), typeof(TestMessage).FullName);

            await broker.PublishMessageAsync(new TestMessage().CreateMessageWrapper());

            await Assert.ThrowsExceptionAsync <Exception>(() => ExecuteProcessAllQueuesAsync(broker));

            Assert.AreEqual(1, broker.MessageDeliveredEventCount);
            Assert.AreEqual(1, broker.MessageDeliveryFailedEventCount);
        }