Пример #1
0
 protected virtual CheckpointTag GivenFromPosition()
 {
     return(CheckpointTag.FromPosition(0, 0, -1));
 }
Пример #2
0
 public void unlock_succeeds()
 {
     _cache.Unlock(CheckpointTag.FromPosition(0, 300, 290));
 }
Пример #3
0
        public void the_state_can_be_retrieved_as_unlocked_and_relocked_at_later_position()
        {
            var state = _cache.TryGetAndLockPartitionState("partition", CheckpointTag.FromPosition(0, 1500, 1400));

            Assert.AreEqual("data", state.State);
        }
 public void null_ready_handler_throws_argument_null_exception()
 {
     var c = new ProjectionCheckpoint(new FakePublisher(), null, false, CheckpointTag.FromPosition(100, 50), 250);
 }
 public void it_can_be_created()
 {
     var c = new ProjectionCheckpoint(
         new FakePublisher(), _readyHandler, true, CheckpointTag.FromPosition(100, 50), 250);
 }
Пример #6
0
 public void null_ready_handler_throws_argument_null_exception()
 {
     new ProjectionCheckpoint(
         _ioDispatcher, new ProjectionVersion(1, 0, 0), null, null,
         CheckpointTag.FromPosition(0, 100, 50), new TransactionFilePositionTagger(0), 250);
 }
Пример #7
0
 public void it_can_be_created()
 {
     new ProjectionCheckpoint(
         _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
         CheckpointTag.FromPosition(0, 100, 50), new TransactionFilePositionTagger(0), 250);
 }
Пример #8
0
 public void does_not_publish_already_published_events()
 {
     _stream.EmitEvents(
         new[]
     {
         new EmittedDataEvent(
             "test_stream", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 100, 50), CheckpointTag.FromPosition(0, 40, 20))
     });
     Assert.AreEqual(0, _consumer.HandledMessages.OfType <ClientMessage.WriteEvents>().Count());
 }
Пример #9
0
 public void publishes_not_yet_published_events_if_expected_tag_is_the_same()
 {
     _stream.EmitEvents(
         new[]
     {
         new EmittedDataEvent(
             "test_stream", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 200, 150), CheckpointTag.FromPosition(0, 100, 50))
     });
     Assert.AreEqual(1, _consumer.HandledMessages.OfType <ClientMessage.WriteEvents>().Count());
 }
Пример #10
0
 public void suggests_a_checkpoint()
 {
     Assert.AreEqual(1, _checkpointHandler.HandledMessages.Count);
     Assert.AreEqual(CheckpointTag.FromPosition(300, 250), _checkpointHandler.HandledMessages[0].CheckpointTag);
 }
Пример #11
0
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();
     _stream       = new EmittedStream(
         "test_stream", new EmittedStream.WriterConfiguration(new EmittedStreamsWriter(_ioDispatcher), new EmittedStream.WriterConfiguration.StreamMetadata(), null, maxWriteBatchLength: 50),
         new ProjectionVersion(1, 0, 0), new TransactionFilePositionTagger(0), CheckpointTag.FromPosition(0, 0, -1),
         _bus, _ioDispatcher, _readyHandler);
     _stream.Start();
 }
Пример #12
0
 public void thorws_invalid_operation_exception_if_not_allowed()
 {
     _cache.TryGetAndLockPartitionState("partition", CheckpointTag.FromPosition(0, 1000, 900));
 }
Пример #13
0
 public void null_user_account_is_allowed()
 {
     new FeedReader(
         _subscriptionDispatcher, null, _testQueryDefinition, CheckpointTag.FromPosition(0, 0, -1), 10,
         Guid.NewGuid(), new NoopEnvelope(), new RealTimeProvider());
 }
Пример #14
0
 protected override void When()
 {
     _feedReader.Handle(
         new EventReaderSubscriptionMessage.EofReached(
             _subscriptionId, CheckpointTag.FromPosition(0, _maxN * 100, _maxN * 100 - 50), _number++));
 }
        public void partitions_locked_at_the_unlock_position_can_be_retrieved_and_relocked_at_later_position()
        {
            var data = _cache.TryGetAndLockPartitionState("partition2", CheckpointTag.FromPosition(25000, 24000));

            Assert.AreEqual("data2", data);
        }
Пример #16
0
 public void does_not_publish_not_yet_published_events_if_expected_tag_is_before_last_event_tag()
 {
     //TODO: is it corrupted dB case?
     _stream.EmitEvents(
         new[]
     {
         new EmittedDataEvent(
             "test_stream", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 200, 150), CheckpointTag.FromPosition(0, 40, 20))
     });
     Assert.AreEqual(0, _consumer.HandledMessages.OfType <ClientMessage.WriteEvents>().Count());
 }
Пример #17
0
 public void setup()
 {
     _readyHandler = new TestCheckpointManagerMessageHandler();
     _stream       = new EmittedStream(
         "test_stream", new EmittedStream.WriterConfiguration(new EmittedStream.WriterConfiguration.StreamMetadata(), null, maxWriteBatchLength: 50),
         new ProjectionVersion(1, 0, 0), new TransactionFilePositionTagger(0), CheckpointTag.FromPosition(0, 40, 30),
         _ioDispatcher, _readyHandler);
     _stream.Start();
     _stream.EmitEvents(
         new[]
     {
         new EmittedDataEvent(
             "test_stream", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 100, 90), null)
     });
 }
Пример #18
0
 public void correct_stream_id_is_set_on_write_events_message()
 {
     _stream.EmitEvents(
         new[]
     {
         new EmittedDataEvent(
             "test_stream", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 200, 150), CheckpointTag.FromPosition(0, 100, 50))
     });
     Assert.AreEqual(
         "test_stream", _consumer.HandledMessages.OfType <ClientMessage.WriteEvents>().Single().EventStreamId);
 }
Пример #19
0
 public void commit_position_less_than_or_equal_to_prepare_position_throws_argument_exception()
 {
     new ProjectionCheckpoint(
         _ioDispatcher, new ProjectionVersion(1, 0, 0), null, _readyHandler,
         CheckpointTag.FromPosition(0, 100, 101), new TransactionFilePositionTagger(0), 250);
 }
Пример #20
0
        public void metadata_include_commit_and_prepare_positions()
        {
            _stream.EmitEvents(
                new[]
            {
                new EmittedDataEvent(
                    "test_stream", Guid.NewGuid(), "type", true, "data", null, CheckpointTag.FromPosition(0, 200, 150), CheckpointTag.FromPosition(0, 100, 50))
            });
            var metaData =
                _consumer.HandledMessages.OfType <ClientMessage.WriteEvents>().Single().Events[0].Metadata
                .ParseCheckpointTagVersionExtraJson(default(ProjectionVersion));

            Assert.AreEqual(200, metaData.Tag.CommitPosition);
            Assert.AreEqual(150, metaData.Tag.PreparePosition);
        }
Пример #21
0
        public void partitions_locked_before_the_unlock_position_cannot_be_retrieved_and_relocked_at_later_position()
        {
            var data = _cache.TryGetAndLockPartitionState("partition1", CheckpointTag.FromPosition(0, 1600, 1500));

            Assert.IsNull(data);
        }
Пример #22
0
 public void setup()
 {
     _publisher    = new FakePublisher();
     _readyHandler = new TestMessageHandler <ProjectionMessage.Projections.ReadyForCheckpoint>();
     _stream       = new EmittedStream("test", _publisher, _readyHandler, false, 50);
     _stream.EmitEvents(
         new[] { new EmittedEvent("stream", Guid.NewGuid(), "type", "data") }, CheckpointTag.FromPosition(200, 150));
 }
 public void commit_position_less_than_or_equal_to_prepare_position_throws_argument_exception()
 {
     var c = new ProjectionCheckpoint(
         new FakePublisher(), _readyHandler, true, CheckpointTag.FromPosition(100, 101), 250);
 }
 public void emit_events_throws_invalid_operation_exception()
 {
     _stream.EmitEvents(
         new[] { new EmittedEvent("stream", Guid.NewGuid(), "type2", "data2") }, CheckpointTag.FromPosition(-1, -1));
 }
Пример #25
0
        public void state_can_be_cached()
        {
            CheckpointTag at = CheckpointTag.FromPosition(0, 100, 90);

            _cache.CacheAndLockPartitionState("partition", new PartitionState("data", null, at), at);
        }
        public void it_cannot_be_updated_forward()
        {
            var newTag = CheckpointTag.FromPosition(100, 50);

            _positionTracker.UpdateByCheckpointTagForward(newTag);
        }
Пример #27
0
 public void when()
 {
     _cache = new PartitionStateCache();
     _cachedAtCheckpointTag = CheckpointTag.FromPosition(0, 1000, 900);
     _cache.CacheAndLockPartitionState("partition", new PartitionState("data", null, _cachedAtCheckpointTag), _cachedAtCheckpointTag);
 }
        the_first_partition_locked_before_the_unlock_position_cannot_be_retrieved_and_relocked_at_later_position()
        {
            var data = _cache.TryGetAndLockPartitionState("partition1", CheckpointTag.FromPosition(25000, 24000));

            Assert.AreEqual("data1", data);
        }
        public void setup()
        {
            _readyHandler = new TestCheckpointManagerMessageHandler();;
            _checkpoint   = new ProjectionCheckpoint(_bus, _readyHandler, CheckpointTag.FromPosition(100, 50), CheckpointTag.FromPosition(0, -1), 250);
            _checkpoint.Start();
            _checkpoint.EmitEvents(
                new[]
            {
                new EmittedEvent("stream2", Guid.NewGuid(), "type", "data2", CheckpointTag.FromPosition(120, 110), null),
                new EmittedEvent("stream2", Guid.NewGuid(), "type", "data4", CheckpointTag.FromPosition(120, 110), null),
            }
                );
            _checkpoint.EmitEvents(
                new[] { new EmittedEvent("stream1", Guid.NewGuid(), "type", "data",
                                         CheckpointTag.FromPosition(140, 130), null) });
            var writes = _consumer.HandledMessages.OfType <ClientMessage.WriteEvents>().ToArray();

            writes[0].Envelope.ReplyWith(
                new ClientMessage.WriteEventsCompleted(writes[0].CorrelationId, writes[0].EventStreamId, 0));
            writes[1].Envelope.ReplyWith(
                new ClientMessage.WriteEventsCompleted(writes[1].CorrelationId, writes[1].EventStreamId, 0));
            _checkpoint.Prepare(CheckpointTag.FromPosition(200, 150));
            //TODO: test whether checkpoint does not allow positions before last emitted event caused by position
        }
 public void null_publisher_throws_argument_null_exception()
 {
     var c = new ProjectionCheckpoint(null, _readyHandler, CheckpointTag.FromPosition(100, 50), 250);
 }