コード例 #1
0
        public void EventListenerWithReturnTypeThrowsException()
        {
            // Arrange
            var testContext = new TestBusContext();
            var hostBuilder = new MicroserviceHostBuilder().WithBusContext(testContext);

            // Act
            void Act() => hostBuilder.AddEventListener <EventWithReturnTypeEventListener>();

            // Assert
            var exception = Assert.ThrowsException <BusConfigurationException>(Act);

            Assert.AreEqual("Method Handle does not have a proper " +
                            "eventlistener signature in type EventWithReturnTypeEventListener", exception.Message);
        }
コード例 #2
0
        public void AddingListenerRegistersProperCommandReceiver()
        {
            // Arrange
            TestBusContext          testContext = new TestBusContext();
            MicroserviceHostBuilder hostBuilder = new MicroserviceHostBuilder()
                                                  .WithQueueName("test.queue")
                                                  .WithBusContext(testContext);

            // Act
            hostBuilder.AddEventListener <CommandListenerDummy>();

            List <MicroserviceCommandListener> result = hostBuilder.CreateHost().CommandListeners.ToList();

            // Assert
            Assert.AreEqual(1, result.Count);

            var firstItem = result.FirstOrDefault();

            Assert.AreEqual("command.queue", firstItem?.Queue);
        }
コード例 #3
0
        public void AddingListenerRegistersProperReceiver()
        {
            // Arrange
            var testContext = new TestBusContext();
            var hostBuilder = new MicroserviceHostBuilder().WithBusContext(testContext);

            // Act
            hostBuilder.AddEventListener <EventListenerDummy>();
            hostBuilder.WithQueueName("test.queue");

            hostBuilder.CreateHost().Start();

            // Assert
            var message = new DummyEvent("TestTopic");

            new EventPublisher(testContext).Publish(message);

            Thread.Sleep(WaitTime);

            Assert.AreEqual(message, EventListenerDummy.HandlesResult);
        }