internal void GivenUnaddressedEnvelope_WhenSubscriberSubscribedToSpecificType_PublishesToSubscriber() { // Arrange var subscribe = new Subscribe <Type>( typeof(MarketOpened), this.receiver.Mailbox, Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); var message = new MarketOpened( new Symbol("AUD/USD", new Venue("FXCM")), StubZonedDateTime.UnixEpoch(), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); var envelope = new Envelope <MarketOpened>( message, null, ComponentAddress.DataService, StubZonedDateTime.UnixEpoch()); this.messageBus.Endpoint.SendAsync(subscribe).Wait(); // Act this.messageBus.Endpoint.SendAsync(envelope).Wait(); Task.Delay(TestAssertionsTaskDelay).Wait(); // Allow sending to complete for assertions // Assert Assert.Contains(envelope, this.receiver.Messages); }
internal void GivenUnaddressedEnvelope_WhenNoSubscribers_HandlesCorrectly() { // Arrange var message = new MarketOpened( new Symbol("AUD/USD", new Venue("FXCM")), StubZonedDateTime.UnixEpoch(), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); var envelope = new Envelope <MarketOpened>( message, null, ComponentAddress.DataService, StubZonedDateTime.UnixEpoch()); // Act this.messageBus.Endpoint.SendAsync(envelope).Wait(); Task.Delay(TestAssertionsTaskDelay).Wait(); // Allow sending to complete for assertions // Assert Assert.Equal(0, this.messageBus.SubscriptionCount); }
internal void GivenAddressedEnvelope_WhenAddressUnknown_SendsToDeadLetters() { // Arrange var message = new MarketOpened( new Symbol("AUD/USD", new Venue("FXCM")), StubZonedDateTime.UnixEpoch(), Guid.NewGuid(), StubZonedDateTime.UnixEpoch()); var envelope = new Envelope <MarketOpened>( message, ComponentAddress.BarProvider, ComponentAddress.DataService, StubZonedDateTime.UnixEpoch()); // Act this.messageBus.Endpoint.SendAsync(envelope).Wait(); Task.Delay(TestAssertionsTaskDelay).Wait(); // Allow sending to complete for assertions // Assert Assert.Contains(envelope, this.messageBus.DeadLetters); }