示例#1
0
        public async Task EventsCanBePublishedAsync()
        {
            // Arrange
            IEventAggregator eventAggregator = new InProcessEventAggregator();
            MockClass        mockClass       = new MockClass(eventAggregator);
            MockEvent        @event          = new MockEvent();

            // Act
            await eventAggregator.PublishAsync(@event);

            // Assert
            Assert.IsNotNull(mockClass.ReceivedAsyncMockEventId);
            Assert.AreEqual(@event.Guid, mockClass.ReceivedAsyncMockEventId);
            Assert.AreEqual(default(Guid), mockClass.ReceivedMockEventId);
            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);
        }