public void should_not_handle_replayed_message_with_unknown_replay_id() { var otherReplayId = Guid.NewGuid(); var message = new FakeCommand(123).ToTransportMessage(); InnerTransport.RaiseMessageReceived(message.ToReplayedTransportMessage(otherReplayId)); Thread.Sleep(10); MessagesForwardedToBus.Count.ShouldEqual(0); }
public void should_only_forward_replayed_messages_during_replay_phase() { Transport.Start(); var transportMessageToForward = new FakeCommand(123).ToTransportMessage(); var normalTransportMessage = new FakeEvent(123).ToTransportMessage(); var replayedTransportMessage = transportMessageToForward.ToReplayedTransportMessage(ReplayId); InnerTransport.RaiseMessageReceived(replayedTransportMessage); InnerTransport.RaiseMessageReceived(normalTransportMessage); MessagesForwardedToBus.Count.ShouldEqual(1); MessagesForwardedToBus.Single().Id.ShouldEqual(transportMessageToForward.Id); }
public void should_not_handle_twice_duplicate_messages() { Transport.Start(); var duplicatedMessage = new FakeCommand(123).ToTransportMessage(); InnerTransport.RaiseMessageReceived(new ReplayPhaseEnded(StartMessageReplayCommand.ReplayId).ToTransportMessage()); InnerTransport.RaiseMessageReceived(duplicatedMessage); InnerTransport.RaiseMessageReceived(duplicatedMessage.ToReplayedTransportMessage(StartMessageReplayCommand.ReplayId)); Wait.Until(() => MessagesForwardedToBus.Count == 1, 150.Milliseconds()); MessagesForwardedToBus.Single().Id.ShouldEqual(duplicatedMessage.Id); }
public void should_force_WasPersisted_for_replayed_messages() { Transport.Start(); var sourceTransportMessage = new FakeCommand(123).ToTransportMessage(); sourceTransportMessage.WasPersisted = null; var replayTransportMessage = sourceTransportMessage.ToReplayedTransportMessage(ReplayId); InnerTransport.RaiseMessageReceived(replayTransportMessage); var forwardedTransportMessage = MessagesForwardedToBus.ExpectedSingle(); forwardedTransportMessage.WasPersisted.ShouldEqual(true); }
public void should_not_lose_messages_when_switching_to_safety_phase() { Transport.Start(); var liveMessageToStack = new FakeCommand(123).ToTransportMessage(); var replayedMessageToPlayAfterStack = new FakeCommand(456).ToTransportMessage(); InnerTransport.RaiseMessageReceived(liveMessageToStack); InnerTransport.RaiseMessageReceived(new ReplayPhaseEnded(StartMessageReplayCommand.ReplayId).ToTransportMessage()); InnerTransport.RaiseMessageReceived(replayedMessageToPlayAfterStack.ToReplayedTransportMessage(StartMessageReplayCommand.ReplayId)); Wait.Until(() => MessagesForwardedToBus.Count >= 2, 150.Milliseconds()); MessagesForwardedToBus.Count.ShouldEqual(2); MessagesForwardedToBus.First().Id.ShouldEqual(liveMessageToStack.Id); MessagesForwardedToBus.Last().Id.ShouldEqual(replayedMessageToPlayAfterStack.Id); }
public void should_force_WasPersisted_for_replayed_messages_during_safety_phase() { Transport.Start(); InnerTransport.RaiseMessageReceived(new ReplayPhaseEnded(ReplayId).ToTransportMessage()); var sourceTransportMessage = new FakeCommand(123).ToTransportMessage(); sourceTransportMessage.WasPersisted = null; var replayTransportMessage = sourceTransportMessage.ToReplayedTransportMessage(ReplayId); InnerTransport.RaiseMessageReceived(replayTransportMessage); Wait.Until(() => MessagesForwardedToBus.Count == 1, 150.Milliseconds()); var forwardedTransportMessage = MessagesForwardedToBus.ExpectedSingle(); forwardedTransportMessage.WasPersisted.ShouldEqual(true); }