Exemplo n.º 1
0
        public void UseConventionsRegistersProperTopics(string messageText)
        {
            // Arrange
            var testContext = new TestBusContext();
            var hostBuilder = new MicroserviceHostBuilder().WithBusContext(testContext);

            // Act
            hostBuilder.UseConventions();

            hostBuilder.CreateHost().Start();

            // Assert
            var message = new DummyEvent("IrrelevantTopic")
            {
                DummyText = messageText
            };

            new EventPublisher(testContext).Publish(message);

            Thread.Sleep(WaitTime);

            Assert.IsNull(EventListenerDummy.HandlesResult);
            Assert.IsNull(EventListenerDummy2.HandlesResult);
            Assert.AreEqual(message, EventListenerDummy3.HandlesResult);
        }
Exemplo n.º 2
0
        public void UseConventionsRegistersProperCommandListeners()
        {
            // Arrange
            var testContext = new TestBusContext();
            var hostBuilder = new MicroserviceHostBuilder()
                              .WithBusContext(testContext);

            // Act
            hostBuilder.UseConventions();

            hostBuilder.CreateHost().Start();

            // Assert
            var message = new GetAnimalsCommand();

            ICommandPublisher publisher = new CommandPublisher(testContext);

            Animal[] animals = publisher.PublishAsync <IEnumerable <Animal> >(message).Result.ToArray();
            Assert.AreEqual(2, animals.Length);
        }