public void send_message_to_all_listeners_for_a_message_type() { var listener1 = new StubListener<Message1>(); var listener2 = new StubListener<Message1>(); var listener3 = new StubListener<Message1>(); var listener4 = new StubListener<Message2>(); events.AddListeners(listener1, listener2, listener3, this, listener4); var message1 = new Message1(); var message2 = new Message2(); events.SendMessage(message1); events.SendMessage(message2); Wait.Until( () => listener1.LastMessage != null && listener2.LastMessage != null && listener3.LastMessage != null && listener4.LastMessage != null); listener1.LastMessage.ShouldBeTheSameAs(message1); listener2.LastMessage.ShouldBeTheSameAs(message1); listener3.LastMessage.ShouldBeTheSameAs(message1); listener4.LastMessage.ShouldBeTheSameAs(message2); }
public void listeners_can_fail_one_at_a_time() { var listener1 = new StubListener<Message1>(); var listener2 = new StubListener<Message1>(); var listener3 = new StubListener<Message1>(); var listener4 = new StubListener<Message2>(); events.AddListeners(listener1, listener2, listener3, this, listener4); events.AddListener(new ErrorCausingHandler()); var message1 = new Message1(); var message2 = new Message2(); events.SendMessage(message1); events.SendMessage(message2); Wait.Until( () => listener1.LastMessage != null && listener2.LastMessage != null && listener3.LastMessage != null && listener4.LastMessage != null); listener1.LastMessage.ShouldBeTheSameAs(message1); listener2.LastMessage.ShouldBeTheSameAs(message1); listener3.LastMessage.ShouldBeTheSameAs(message1); listener4.LastMessage.ShouldBeTheSameAs(message2); }
public void SetUp() { theMessage = new Message1(); theOriginalEnvelope = new Envelope { ReplyUri = "lq://foo".ToUri() }; }
public void consumed_messages() { var message = new Message1(); var bus = new RecordingServiceBus(); bus.Consume(message); bus.Consumed.Single().ShouldBeTheSameAs(message); }
public void send_records() { var message = new Message1(); var bus = new RecordingServiceBus(); bus.Send(message); bus.Sent.Single().ShouldBeTheSameAs(message); }
public void simple_handlers_registered() { var theMessage = new Message1(); events.SendMessage(theMessage); Wait.Until(() => handler.Message != null); handler.Message.ShouldBeTheSameAs(theMessage); }
public void enqueue_an_oject_array() { var messages = new FubuTransportation.Runtime.Invocation.InvocationContext(new Envelope{Message = new Message1()}, new HandlerChain()); var m1 = new Message1(); var m2 = new Message2(); messages.EnqueueCascading(new object[]{m1, m2}); messages.OutgoingMessages().ShouldHaveTheSameElementsAs(m1, m2); }
public void send_delayed_by_time_span() { var message = new Message1(); var bus = new RecordingServiceBus(); bus.DelaySend(message, 5.Minutes()); bus.DelayedSent.Single().Message.ShouldBeTheSameAs(message); bus.DelayedSent.Single().Delay.ShouldEqual(5.Minutes()); }
public void SubscriberShouldReceiveMessage_WhenMessagePublished() { var mock = new Mock<ISubscriber<Message1>>(); var eventAggregator = new EventAggregator(); eventAggregator.Subscribe(mock.Object); var msg = new Message1(); eventAggregator.Publish(msg); mock.Verify(s => s.Handle(msg)); }
public void enqueue() { var messages = new FubuMVC.Core.ServiceBus.Runtime.Invocation.InvocationContext(new Envelope{Message = new Message1()}, new HandlerChain()); var m1 = new Message1(); var m2 = new Message2(); messages.EnqueueCascading(m1); messages.EnqueueCascading(m2); messages.OutgoingMessages().ShouldHaveTheSameElementsAs(m1, m2); }
public void send_delayed_by_time() { var time = DateTime.Today.AddHours(5); var message = new Message1(); var bus = new RecordingServiceBus(); bus.DelaySend(message, time); bus.DelayedSent.Single().Message.ShouldBeTheSameAs(message); bus.DelayedSent.Single().Time.ShouldEqual(time); }
public void send_to_destination() { var destination = new Uri("memory://blah"); var message = new Message1(); var bus = new RecordingServiceBus(); bus.Send(destination, message); var sentTo = bus.SentDirectlyTo.Single(); sentTo.Destination.ShouldEqual(destination); sentTo.Message.ShouldBeTheSameAs(message); }
public void create_and_send_with_timespan_delayed() { var message = new Message1(); var delayed = new FubuTransportation.Runtime.Cascading.DelayedResponse(message, 5.Minutes()); var original = MockRepository.GenerateMock<Envelope>(); var response = new Envelope(); original.Stub(x => x.ForResponse(message)).Return(response); delayed.CreateEnvelope(original).ShouldBeTheSameAs(response); response.ExecutionTime.ShouldEqual(delayed.Time); }
public void send_and_wait() { var message = new Message1(); var bus = new RecordingServiceBus(); bus.SendAndWait(message).Wait(); // Checking for messages sent bus.Sent.Single().ShouldBeTheSameAs(message); // Checking for awaited calls bus.Await.Single().ShouldBeTheSameAs(message); }
static async Task MainAsync() { Console.Title = "Samples.Azure.ServiceBus.Endpoint1"; #region config var endpointConfiguration = new EndpointConfiguration("Samples.Azure.ServiceBus.Endpoint1"); endpointConfiguration.SendFailedMessagesTo("error"); var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>(); transport.ConnectionString(Environment.GetEnvironmentVariable("AzureServiceBus.ConnectionString")); transport.UseTopology<ForwardingTopology>(); #endregion endpointConfiguration.UsePersistence<InMemoryPersistence>(); endpointConfiguration.UseSerialization<JsonSerializer>(); endpointConfiguration.EnableInstallers(); var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); try { Console.WriteLine("Press 'enter' to send a message"); Console.WriteLine("Press any other key to exit"); while (true) { var key = Console.ReadKey(); Console.WriteLine(); if (key.Key != ConsoleKey.Enter) { return; } var orderId = Guid.NewGuid(); var message = new Message1 { Property = "Hello from Endpoint1" }; await endpointInstance.Send("Samples.Azure.ServiceBus.Endpoint2", message) .ConfigureAwait(false); Console.WriteLine("Message1 sent"); } } finally { await endpointInstance.Stop() .ConfigureAwait(false); } }
public void create_and_send_to_correct_destination() { var destination = new Uri("memory://blah"); var message = new Message1(); var sendDirectlyTo = new SendDirectlyTo(destination, message); var original = MockRepository.GenerateMock<Envelope>(); var response = new Envelope(); original.Stub(x => x.ForSend(message)).Return(response); sendDirectlyTo.CreateEnvelope(original).ShouldBeTheSameAs(response); response.Destination.ShouldBe(destination); }
public void has_to_set_the_destination_header() { var message = new Message1(); var respondToSender = new RespondToSender(message); var original = MockRepository.GenerateMock<Envelope>(); original.ReplyUri = new Uri("memory://me/reply"); var response = new Envelope(); original.Stub(x => x.ForResponse(message)).Return(response); respondToSender.CreateEnvelope(original).ShouldBeTheSameAs(response); response.Destination.ShouldBe(original.ReplyUri); }
static async Task MainAsync() { #region config BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.Azure.ServiceBus.Endpoint1"); busConfiguration.SendFailedMessagesTo("error"); busConfiguration.UseTransport<AzureServiceBusTransport>() .ConnectionString(Environment.GetEnvironmentVariable("SamplesAzureServiceBusConnection")); #endregion busConfiguration.UsePersistence<InMemoryPersistence>(); busConfiguration.UseSerialization<JsonSerializer>(); busConfiguration.EnableInstallers(); IEndpointInstance endpoint = await Endpoint.Start(busConfiguration); try { Console.WriteLine("Press 'enter' to send a message"); Console.WriteLine("Press any other key to exit"); while (true) { ConsoleKeyInfo key = Console.ReadKey(); Console.WriteLine(); if (key.Key != ConsoleKey.Enter) { return; } Guid orderId = Guid.NewGuid(); Message1 message = new Message1 { Property = "Hello from Endpoint1" }; await endpoint.Send("Samples.Azure.ServiceBus.Endpoint2", message); Console.WriteLine("Message1 sent"); } } finally { await endpoint.Stop(); } }
static async Task AsyncMain() { Console.Title = "Samples.Azure.StorageQueues.Endpoint1"; EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.Azure.StorageQueues.Endpoint1"); #region config endpointConfiguration.UseTransport<AzureStorageQueueTransport>(); #endregion endpointConfiguration.UsePersistence<InMemoryPersistence>(); endpointConfiguration.UseSerialization<JsonSerializer>(); endpointConfiguration.EnableInstallers(); endpointConfiguration.SendFailedMessagesTo("error"); IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration); try { Console.WriteLine("Press 'enter' to send a message"); Console.WriteLine("Press any other key to exit"); while (true) { ConsoleKeyInfo key = Console.ReadKey(); Console.WriteLine(); if (key.Key != ConsoleKey.Enter) { return; } Guid orderId = Guid.NewGuid(); Message1 message = new Message1 { Property = "Hello from Endpoint1" }; await endpoint.Send("Samples.Azure.StorageQueues.Endpoint2", message); Console.WriteLine("Message1 sent"); } } finally { await endpoint.Stop(); } }
public void records_outgoing_on_the_invocation_context() { var context = ObjectMother.InvocationContext(); var handling = new AsyncHandling(context); var expectedMessage = new Message1(); var task1 = Task.Factory.StartNew(() => { Thread.Sleep(100); return expectedMessage; }); handling.Push(task1); handling.WaitForAll(); context.OutgoingMessages().Single() .ShouldBeTheSameAs(expectedMessage); }
static void Main() { Console.Title = "Samples.Azure.ServiceBus.Endpoint1"; #region config BusConfiguration busConfiguration = new BusConfiguration(); busConfiguration.EndpointName("Samples.Azure.ServiceBus.Endpoint1"); busConfiguration.ScaleOut().UseSingleBrokerQueue(); busConfiguration.UseTransport<AzureServiceBusTransport>() .ConnectionString(Environment.GetEnvironmentVariable("SamplesAzureServiceBusConnection")); #endregion busConfiguration.UsePersistence<InMemoryPersistence>(); busConfiguration.UseSerialization<JsonSerializer>(); busConfiguration.EnableInstallers(); using (IBus bus = Bus.Create(busConfiguration).Start()) { Console.WriteLine("Press 'enter' to send a message"); Console.WriteLine("Press any other key to exit"); while (true) { ConsoleKeyInfo key = Console.ReadKey(); Console.WriteLine(); if (key.Key != ConsoleKey.Enter) { return; } Guid orderId = Guid.NewGuid(); Message1 message = new Message1 { Property = "Hello from Endpoint1" }; bus.Send("Samples.Azure.ServiceBus.Endpoint2", message); Console.WriteLine("Message1 sent"); } } }
public void Record(Message1 message) { _message1.SetResult(message); }
public void Handle(Message1 message) { _tracker.Record(message); }
public Message2 Handle(Message1 message) { return(new Message2 { Name = message.Name }); }
public void parent_that_is_not_original_creating_child_envelope() { var parent = new Envelope { CorrelationId = Guid.NewGuid().ToString(), OriginalId = Guid.NewGuid().ToString() }; var childMessage = new Message1(); var child = parent.ForResponse(childMessage); child.Message.ShouldBeTheSameAs(childMessage); child.OriginalId.ShouldEqual(parent.OriginalId); child.ParentId.ShouldEqual(parent.CorrelationId); }
public void Go(Message1 input) { }
public Task Handle(Message1 message, IMessageHandlerContext context) { throw new NotImplementedException(); }
public abstract Task Handle(Message1 message);
public void Handle(Message1 message) { }
public void remove_listener() { var listener1 = new StubListener<Message1>(); var listener2 = new StubListener<Message1>(); var listener3 = new StubListener<Message1>(); var listener4 = new StubListener<Message2>(); var listener5 = MockRepository.GenerateMock<IListener<Message1>>(); events.AddListeners(listener1, listener2, listener3, this, listener4, listener5); var message1 = new Message1(); events.RemoveListener(listener5); events.SendMessage(message1); listener5.AssertWasNotCalled(x => x.Handle(message1)); }
public void Handle(Message1 message, IService <T> service) { }
public static Task Simple1(Message1 message) { LastMessage1 = message; return(Task.CompletedTask); }
public abstract Task Handle(Message1 message, IMessageHandlerContext context);
public void do_not_set_destination_or_response_if_requested_header_does_not_exist_in_parent() { var parent = new Envelope { CorrelationId = Guid.NewGuid().ToString(), OriginalId = Guid.NewGuid().ToString(), Source = "foo://bar".ToUri() }; parent.Headers.Has(Envelope.ReplyRequestedKey).ShouldBeFalse(); var childMessage = new Message1(); var child = parent.ForResponse(childMessage); child.Headers.Has(Envelope.ResponseIdKey).ShouldBeFalse(); child.Destination.ShouldBeNull(); }
public void Handle(Message1 message) { }
public void if_reply_requested_header_exists_in_parent_and_does_NOT_match_the_message_type() { var parent = new Envelope { CorrelationId = Guid.NewGuid().ToString(), OriginalId = Guid.NewGuid().ToString(), ReplyUri = "foo://bar".ToUri(), ReplyRequested = typeof(Message2).Name }; var childMessage = new Message1(); var child = parent.ForResponse(childMessage); child.Headers.Has(Envelope.ResponseIdKey).ShouldBeFalse(); child.Destination.ShouldBeNull(); }
public void Go(Message1 message) { }
public void if_reply_requested_header_exists_in_parent_and_matches_the_message_type() { var parent = new Envelope { CorrelationId = Guid.NewGuid().ToString(), OriginalId = Guid.NewGuid().ToString(), ReplyUri = "foo://bar".ToUri(), ReplyRequested = typeof(Message1).Name }; var childMessage = new Message1(); var child = parent.ForResponse(childMessage); child.Headers[Envelope.ResponseIdKey].ShouldEqual(parent.CorrelationId); child.Destination.ShouldEqual(parent.ReplyUri); }
public void SetUp() { theEvents = MockRepository.GenerateMock<IEventAggregator>(); theListener = new ReplyListener<Message1>(theEvents, correlationId, 10.Minutes()); theMessage = new Message1(); var envelope = new EnvelopeToken { Message = theMessage }; envelope.Headers[Envelope.ResponseIdKey] = correlationId; theListener.Handle(new EnvelopeReceived { Envelope = envelope }); }
void Start() { InitComponents(); SendBirdClient.ChannelHandler channelHandler = new SendBirdClient.ChannelHandler(); channelHandler.OnMessageReceived = (BaseChannel channel, BaseMessage message) => { // Draw new messages if user is on the channel. if (currentChannel.Url == channel.Url) { if (message is UserMessage) { string text; text = UserMessageRichText((UserMessage)message); if (text.Contains("3dObject")) { string[] values = text.Split(','); Message1 obj = XMLSerializer.Deserialize(values[1]); Console.WriteLine("Text: " + values[1] + " Received obj World Position: x " + obj.transformX + " y: " + obj.transformY + " z: " + obj.transformZ); txtOpenChannelContent.text = txtOpenChannelContent.text + ("Text: " + values[1] + " Received obj Position: x " + obj.transformX + " y: " + obj.transformY + " z: " + obj.transformZ + "\n"); Vector3 targetPos; targetPos.x = obj.transformX; targetPos.y = obj.transformY; targetPos.z = obj.transformZ; Vector3 recObjPos = LocationHelper.calculatePosition(locationManager.getOrigWorldPosition(), targetPos); Console.WriteLine("\n\nReceived obj calculated Position: x " + recObjPos.x + " y: " + recObjPos.y + " z: " + recObjPos.z); GameObject clone = Instantiate(prefabObject, recObjPos, Quaternion.identity); } if (channel.IsOpenChannel()) { txtOpenChannelContent.text = txtOpenChannelContent.text + (UserMessageRichText((UserMessage)message) + "\n"); } else { txtGroupChannelContent.text = txtGroupChannelContent.text + (UserMessageRichText((UserMessage)message) + "\n"); Console.WriteLine(message.ToString()); } } else if (message is FileMessage) { if (channel.IsOpenChannel()) { txtOpenChannelContent.text = txtOpenChannelContent.text + (FileMessageRichText((FileMessage)message) + "\n"); } else { txtGroupChannelContent.text = txtGroupChannelContent.text + (FileMessageRichText((FileMessage)message) + "\n"); } } else if (message is AdminMessage) { if (channel.IsOpenChannel()) { txtOpenChannelContent.text = txtOpenChannelContent.text + (AdminMessageRichText((AdminMessage)message) + "\n"); } else { txtGroupChannelContent.text = txtGroupChannelContent.text + (AdminMessageRichText((AdminMessage)message) + "\n"); } } ScrollToBottom(); } }; SendBirdClient.AddChannelHandler("default", channelHandler); }