public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();
     _checkpoint   = new ProjectionCheckpoint(
         _bus, _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
         CheckpointTag.FromPosition(0, 100, 50), new TransactionFilePositionTagger(0), 250, 1);
     _checkpoint.Start();
     _checkpoint.ValidateOrderAndEmitEvents(
         new[] {
         new EmittedEventEnvelope(
             new EmittedDataEvent(
                 "stream2", Guid.NewGuid(), "type", true, "data2", null,
                 CheckpointTag.FromPosition(0, 120, 110), null)),
         new EmittedEventEnvelope(
             new EmittedDataEvent(
                 "stream2", Guid.NewGuid(), "type", true, "data4", null,
                 CheckpointTag.FromPosition(0, 120, 110), null)),
     });
     _checkpoint.ValidateOrderAndEmitEvents(
         new[] {
         new EmittedEventEnvelope(
             new EmittedDataEvent(
                 "stream1", Guid.NewGuid(), "type", true, "data", null,
                 CheckpointTag.FromPosition(0, 140, 130), null))
     });
     _checkpoint.ValidateOrderAndEmitEvents(
         new[] {
         new EmittedEventEnvelope(
             new EmittedDataEvent(
                 "stream1", Guid.NewGuid(), "type", true, "data", null,
                 CheckpointTag.FromPosition(0, 160, 150), null))
     });
     _checkpoint.Prepare(CheckpointTag.FromPosition(0, 200, 150));
 }
        public void setup()
        {
            _readyHandler = new TestCheckpointManagerMessageHandler();
            _checkpoint   = new ProjectionCheckpoint(
                _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
                CheckpointTag.FromPosition(0, 100, 50), new TransactionFilePositionTagger(0),
                CheckpointTag.FromPosition(0, 0, -1), 250);
            _checkpoint.Start();
            _checkpoint.ValidateOrderAndEmitEvents(
                new[]
            {
                new EmittedEventEnvelope(
                    new EmittedDataEvent(
                        "stream2", Guid.NewGuid(), "type", true, "data2", null, CheckpointTag.FromPosition(0, 120, 110), null)),
                new EmittedEventEnvelope(
                    new EmittedDataEvent(
                        "stream2", Guid.NewGuid(), "type", true, "data4", null, CheckpointTag.FromPosition(0, 120, 110), null)),
            });
            _checkpoint.ValidateOrderAndEmitEvents(
                new[]
            {
                new EmittedEventEnvelope(
                    new EmittedDataEvent(
                        "stream1", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 140, 130), null))
            });
            var writes = _consumer.HandledMessages.OfType <ClientMessage.WriteEvents>().ToArray();

            writes[0].Envelope.ReplyWith(new ClientMessage.WriteEventsCompleted(writes[0].CorrelationId, 0, 0));
            writes[1].Envelope.ReplyWith(new ClientMessage.WriteEventsCompleted(writes[1].CorrelationId, 0, 0));
            _checkpoint.Prepare(CheckpointTag.FromPosition(0, 200, 150));
            //TODO: test whether checkpoint does not allow positions before last emitted event caused by position
        }
コード例 #3
0
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();
     _checkpoint   = new ProjectionCheckpoint(
         _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
         CheckpointTag.FromPosition(0, 100, 50), new TransactionFilePositionTagger(0), 250);
     try
     {
         _checkpoint.ValidateOrderAndEmitEvents(
             new[]
         {
             new EmittedEventEnvelope(
                 new EmittedDataEvent(
                     "stream1", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 140, 130), null))
         });
         _checkpoint.ValidateOrderAndEmitEvents(
             new[]
         {
             new EmittedEventEnvelope(
                 new EmittedDataEvent(
                     "stream1", Guid.NewGuid(), "type", true, "data2", null, CheckpointTag.FromPosition(0, 120, 110), null))
         });
     }
     catch (Exception ex)
     {
         _lastException = ex;
     }
 }
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();
     _checkpoint   = new ProjectionCheckpoint(
         _readDispatcher, _writeDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
         CheckpointTag.FromPosition(100, 50), new TransactionFilePositionTagger(),
         CheckpointTag.FromPosition(0, -1), 250);
     _checkpoint.Start();
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
     {
         new EmittedDataEvent(
             "stream2", Guid.NewGuid(), "type1", "data2", null, CheckpointTag.FromPosition(120, 110), null),
         new EmittedDataEvent(
             "stream3", Guid.NewGuid(), "type2", "data3", null, CheckpointTag.FromPosition(120, 110), null),
         new EmittedDataEvent(
             "stream2", Guid.NewGuid(), "type3", "data4", null, CheckpointTag.FromPosition(120, 110), null),
     });
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
     {
         new EmittedDataEvent(
             "stream1", Guid.NewGuid(), "type4", "data", null, CheckpointTag.FromPosition(140, 130), null)
     });
 }
        public void should_not_write_a_secong_group_until_the_first_write_completes()
        {
            _checkpoint.ValidateOrderAndEmitEvents(
                new[]
            {
                new EmittedDataEvent(
                    "stream1", Guid.NewGuid(), "type", "data", null, CheckpointTag.FromPosition(170, 160), null)
            });
            var writeRequests =
                _consumer.HandledMessages.OfType <ClientMessage.WriteEvents>().Where(v => v.EventStreamId == "stream1");
            var writeEvents = writeRequests.Single();

            writeEvents.Envelope.ReplyWith(new ClientMessage.WriteEventsCompleted(writeEvents.CorrelationId, 0));
            Assert.AreEqual(2, writeRequests.Count());
        }
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();
     _checkpoint   = new ProjectionCheckpoint(
         _bus, _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
         CheckpointTag.FromPosition(0, 100, 50), new TransactionFilePositionTagger(0), 250, AllowedWritesInFlight.Unbounded);
     _checkpoint.Start();
     _checkpoint.ValidateOrderAndEmitEvents(
         new[]
     {
         new EmittedEventEnvelope(
             new EmittedDataEvent(
                 "stream1", Guid.NewGuid(), "type1", true, "data1", null, CheckpointTag.FromPosition(0, 120, 110), null)),
         new EmittedEventEnvelope(
             new EmittedDataEvent(
                 "stream2", Guid.NewGuid(), "type2", true, "data2", null, CheckpointTag.FromPosition(0, 120, 110), null)),
         new EmittedEventEnvelope(
             new EmittedDataEvent(
                 "stream3", Guid.NewGuid(), "type3", true, "data3", null, CheckpointTag.FromPosition(0, 120, 110), null)),
     });
 }