public void SetUp()
 {
     _bus = new FakePublisher();
     _manager = new TwoPhaseCommitRequestManager(_bus, 2, 2);
     _correlationID = Guid.NewGuid();
     _manager.Handle(new ReplicationMessage.WriteRequestCreated(_correlationID,
                                                                new NoopEnvelope(),
                                                                "test-stream",
                                                                -1,
                                                                new Event[0]));
     _prepareAck = new ReplicationMessage.PrepareAck(_correlationID, 0, PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd);
     _commitAck = new ReplicationMessage.CommitAck(_correlationID, 0, 0);
 }
 public void SetUp()
 {
     _bus           = new FakePublisher();
     _manager       = new TwoPhaseCommitRequestManager(_bus, 2, 2);
     _correlationID = Guid.NewGuid();
     _manager.Handle(new ReplicationMessage.WriteRequestCreated(_correlationID,
                                                                new NoopEnvelope(),
                                                                "test-stream",
                                                                -1,
                                                                new Event[0]));
     _prepareAck = new ReplicationMessage.PrepareAck(_correlationID, 0, PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd);
     _commitAck  = new ReplicationMessage.CommitAck(_correlationID, 0, 0);
 }
        public void SetUp()
        {
            _bus = new FakePublisher();
            _manager = new TwoPhaseCommitRequestManager(_bus, 2, 2);

            _correlationID = Guid.NewGuid();

            _manager.Handle(new ReplicationMessage.WriteRequestCreated(
                                _correlationID,
                                new NoopEnvelope(),
                                "test-stream",
                                -1,
                                new[]
                                {
                                    new Event(Guid.NewGuid(), "test-event-type", false,  null, null),
                                    new Event(Guid.NewGuid(), "test-event-type", false,  null, null),
                                    new Event(Guid.NewGuid(), "test-event-type", false,  null, null)
                                }));
        }
        public void SetUp()
        {
            _bus     = new FakePublisher();
            _manager = new TwoPhaseCommitRequestManager(_bus, 2, 2);

            _correlationID = Guid.NewGuid();

            _manager.Handle(new ReplicationMessage.WriteRequestCreated(
                                _correlationID,
                                new NoopEnvelope(),
                                "test-stream",
                                -1,
                                new[]
            {
                new Event(Guid.NewGuid(), "test-event-type", false, null, null),
                new Event(Guid.NewGuid(), "test-event-type", false, null, null),
                new Event(Guid.NewGuid(), "test-event-type", false, null, null)
            }));
        }
        public void should_succeed_if_all_prepare_and_commit_acks_was_received()
        {
            _manager.Handle(new ReplicationMessage.PrepareAck(_correlationID, _startingLogPosition, PrepareFlags.TransactionBegin));
            _manager.Handle(new ReplicationMessage.PrepareAck(_correlationID, _startingLogPosition + 1, PrepareFlags.None));
            _manager.Handle(new ReplicationMessage.PrepareAck(_correlationID, _startingLogPosition + 2, PrepareFlags.TransactionEnd));

            _manager.Handle(new ReplicationMessage.PrepareAck(_correlationID, _startingLogPosition, PrepareFlags.TransactionBegin));
            _manager.Handle(new ReplicationMessage.PrepareAck(_correlationID, _startingLogPosition + 1, PrepareFlags.None));
            _manager.Handle(new ReplicationMessage.PrepareAck(_correlationID, _startingLogPosition + 2, PrepareFlags.TransactionEnd));

            _manager.Handle(new ReplicationMessage.CommitAck(_correlationID, _startingLogPosition, _startingLogPosition));
            _manager.Handle(new ReplicationMessage.CommitAck(_correlationID, _startingLogPosition, _startingLogPosition));

            Assert.That(_bus.Messages.ContainsSingle <ReplicationMessage.RequestCompleted>(m => m.Success == true));
        }
        public void ignore_prepare_timeout_after_switched_to_commit_phase()
        {
            _manager.Handle(_prepareAck);
            _manager.Handle(_prepareAck);

            _manager.Handle(new ReplicationMessage.PreparePhaseTimeout(_correlationID));

            Assert.That(_bus.Messages.ContainsNo <ReplicationMessage.RequestCompleted>(m => m.Success == false));
        }