public When_a_consumer_has_multiple_handlers() { mockBuilder = new MockBuilder(); var queue = new Queue("test_queue", false); var countdownEvent = new CountdownEvent(3); mockBuilder.Bus.Advanced.Consume(queue, x => x .Add <MyMessage>((message, info) => TaskHelpers.ExecuteSynchronously(() => { myMessageResult = message.Body; countdownEvent.Signal(); })) .Add <MyOtherMessage>((message, info) => TaskHelpers.ExecuteSynchronously(() => { myOtherMessageResult = message.Body; countdownEvent.Signal(); })) .Add <IAnimal>((message, info) => TaskHelpers.ExecuteSynchronously(() => { animalResult = message.Body; countdownEvent.Signal(); }))); Deliver(new MyMessage { Text = "Hello Polymorphs!" }); Deliver(new MyOtherMessage { Text = "Hello Isomorphs!" }); Deliver(new Dog()); countdownEvent.Wait(1000); }
public When_a_message_is_received() { mockBuilder = new MockBuilder(); mockBuilder.SendReceive.Receive("the_queue", x => x .Add <MyMessage>(message => deliveredMyMessage = message) .Add <MyOtherMessage>(message => deliveredMyOtherMessage = message)); DeliverMessage("{ Text: \"Hello World :)\" }", "EasyNetQ.Tests.MyMessage, EasyNetQ.Tests"); DeliverMessage("{ Text: \"Goodbye Cruel World!\" }", "EasyNetQ.Tests.MyOtherMessage, EasyNetQ.Tests"); DeliverMessage("{ Text: \"Shouldn't get this\" }", "EasyNetQ.Tests.Unknown, EasyNetQ.Tests"); }
public void The_reliable_attribute_should_be_able_to_be_false() { MyOtherMessage message = new MyOtherMessage(); object[] attributes = message.GetType().GetCustomAttributes(typeof (ReliableAttribute), false); Assert.That(attributes.Length, Is.GreaterThan(0)); foreach (ReliableAttribute reliable in attributes) { Assert.That(reliable.Enabled, Is.False); } }
public void SetUp() { //mockBuilder = new MockBuilder(x => x.Register<IEasyNetQLogger, ConsoleLogger>()); mockBuilder = new MockBuilder(); mockBuilder.Bus.Receive("the_queue", x => x .Add<MyMessage>(message => deliveredMyMessage = message) .Add<MyOtherMessage>(message => deliveredMyOtherMessage = message)); DeliverMessage("{ Text: \"Hello World :)\" }", "EasyNetQ.Tests.MyMessage:EasyNetQ.Tests"); DeliverMessage("{ Text: \"Goodbye Cruel World!\" }", "EasyNetQ.Tests.MyOtherMessage:EasyNetQ.Tests"); DeliverMessage("{ Text: \"Shoudn't get this\" }", "EasyNetQ.Tests.Unknown:EasyNetQ.Tests"); }
public void SetUp() { //mockBuilder = new MockBuilder(x => x.Register<IEasyNetQLogger, ConsoleLogger>()); mockBuilder = new MockBuilder(); mockBuilder.Bus.Receive("the_queue", x => x .Add <MyMessage>(message => deliveredMyMessage = message) .Add <MyOtherMessage>(message => deliveredMyOtherMessage = message)); DeliverMessage("{ Text: \"Hello World :)\" }", "EasyNetQ.Tests.MyMessage:EasyNetQ.Tests"); DeliverMessage("{ Text: \"Goodbye Cruel World!\" }", "EasyNetQ.Tests.MyOtherMessage:EasyNetQ.Tests"); DeliverMessage("{ Text: \"Shoudn't get this\" }", "EasyNetQ.Tests.Unknown:EasyNetQ.Tests"); }
public void The_reliable_attribute_should_be_able_to_be_false() { MyOtherMessage message = new MyOtherMessage(); object[] attributes = message.GetType().GetCustomAttributes(typeof(ReliableAttribute), false); Assert.That(attributes.Length, Is.GreaterThan(0)); foreach (ReliableAttribute reliable in attributes) { Assert.That(reliable.Enabled, Is.False); } }
private static void Send() { var bus = RabbitHutch.CreateBus("host=localhost"); var rand = new Random(); var message = new MyMessage { Name = $"User-{rand.Next(1, 200)}", ShoeSize = rand.Next(1, 50), Address = $"{rand.Next(1, 200)}Next Lane" }; var myOtherMessage = new MyOtherMessage { Address = $"{rand.Next(1, 200)}Next Lane", Taxes = Convert.ToDecimal(rand.NextDouble()) }; bus.Send("My.Queue", message); bus.Send("My.Queue", myOtherMessage); Console.WriteLine("sent two different messages...."); Thread.Sleep(1000); }
private static void Send() { var rand = new Random(); var bus = RabbitHutch.CreateBus("host=localhost"); while (true) { var message = new MyMessage() { Name = "Test name " + rand.Next(10), Age = rand.Next(0, 100) }; var otherMessage = new MyOtherMessage() { Address = "Sofia" + rand.Next(1000, 10000), Taxes = Convert.ToDecimal(rand.NextDouble()) }; bus.Send("my.queue", message); bus.Send("my.queue", otherMessage); Console.WriteLine("Send 2 different message"); Thread.Sleep(1000); } }
public void Consume(MyOtherMessage message) { }
public Task Handle(MyOtherMessage message, IMessageHandlerContext context) { TestContext.SecondMessageReceived = true; return(Task.FromResult(0)); }
public void OnMyOtherMessage(MyOtherMessage msg) { receivedMessages.Add(msg); calledMethods.Add(nameof(OnMyOtherMessage)); }
public void Handle(MyOtherMessage m) { }