Пример #1
0
        public void EventsCanBePublished()
        {
            // Arrange
            IEventAggregator eventAggregator = new InProcessEventAggregator();
            MockClass        mockClass       = new MockClass(eventAggregator);
            MockEvent        @event          = new MockEvent();

            // Act
            eventAggregator.Publish(@event);

            // Assert
            Assert.IsNotNull(mockClass.ReceivedMockEventId);
            Assert.AreEqual(@event.Guid, mockClass.ReceivedMockEventId);
            Assert.AreEqual(default(Guid), mockClass.ReceivedAsyncMockEventId);
            Assert.AreEqual(default(Guid), mockClass.ReceivedAutoMockEventId);
            Assert.AreEqual(default(Guid), mockClass.ReceivedAutoAsyncMockEventId);
        }
Пример #2
0
        public async Task AutoUnSubscribeWorks()
        {
            // Arrange
            IEventAggregator eventAggregator = new InProcessEventAggregator();
            MockClass        mockClass       = new MockClass(eventAggregator);

            eventAggregator.SubscribeAllHandlers(mockClass);
            eventAggregator.UnsubscribeAllHandlers(mockClass);
            MockEvent @event = new MockEvent();

            // Act
            // ReSharper disable once MethodHasAsyncOverload
            //     ^ Actually want to test non-async method as well
            eventAggregator.Publish(@event);
            await eventAggregator.PublishAsync(@event);

            // Assert
            Assert.AreEqual(default(Guid), mockClass.ReceivedAutoMockEventId);
            Assert.AreEqual(default(Guid), mockClass.ReceivedAutoAsyncMockEventId);
        }