Beispiel #1
0
        protected override void When()
        {
            var tag0 = CheckpointTag.FromByStreamPosition(0, "", 0, null, -1, 10000);
            var tag1 = CheckpointTag.FromByStreamPosition(0, "", 1, null, -1, 10000);

            _bus.Publish(
                EventReaderSubscriptionMessage.CommittedEventReceived.Sample(
                    new ResolvedEvent(
                        "catalog",
                        0,
                        "catalog",
                        0,
                        false,
                        new TFPos(120, 110),
                        _eventId,
                        "$@",
                        false,
                        "account-00",
                        ""),
                    tag0,
                    _subscriptionId,
                    0));
            _bus.Publish(
                EventReaderSubscriptionMessage.CommittedEventReceived.Sample(
                    new ResolvedEvent(
                        "catalog",
                        1,
                        "catalog",
                        1,
                        false,
                        new TFPos(220, 210),
                        Guid.NewGuid(),
                        "$@",
                        false,
                        "account-01",
                        ""),
                    tag1,
                    _subscriptionId,
                    1));
            var spoolRequests = HandledMessages.OfType <ReaderSubscriptionManagement.SpoolStreamReading>().ToArray();

            _bus.Publish(
                new PartitionProcessingResult(
                    _workerId,
                    _masterProjectionId,
                    spoolRequests[1].SubscriptionId,
                    "account-01",
                    Guid.Empty,
                    CheckpointTag.FromByStreamPosition(0, "", 1, "account-01", long.MaxValue, 10000),
                    "{\"data\":2}"));
            _bus.Publish(
                new PartitionProcessingResult(
                    _workerId,
                    _masterProjectionId,
                    spoolRequests[0].SubscriptionId,
                    "account-00",
                    Guid.Empty,
                    CheckpointTag.FromByStreamPosition(0, "", 0, "account-00", long.MaxValue, 10000),
                    "{\"data\":1}"));
        }
Beispiel #2
0
 protected override void When()
 {
     _bus.Publish(
         EventReaderSubscriptionMessage.CommittedEventReceived.Sample(
             new ResolvedEvent(
                 "account-01", -1, "account-01", 0, false, new TFPos(120, 110), Guid.NewGuid(),
                 "handle_this_type", false, "data", "metadata"),
             CheckpointTag.FromByStreamPosition(0, "", 0, "account-01", 0, 500), _subscriptionId, 0));
     _bus.Publish(
         EventReaderSubscriptionMessage.CommittedEventReceived.Sample(
             new ResolvedEvent(
                 "account-01", -1, "account-01", 1, false, new TFPos(220, 210), _eventId, "handle_this_type",
                 false, "data", "metadata"), CheckpointTag.FromByStreamPosition(0, "", 0, "account-01", 1, 500),
             _subscriptionId, 1));
     _bus.Publish(
         new EventReaderSubscriptionMessage.PartitionEofReached(
             _subscriptionId, CheckpointTag.FromByStreamPosition(0, "", 0, "account-01", int.MaxValue, 500),
             "account-01", 2));
     _bus.Publish(
         EventReaderSubscriptionMessage.CommittedEventReceived.Sample(
             new ResolvedEvent(
                 "account-02", -1, "account-02", 0, false, new TFPos(220, 210), _eventId, "handle_this_type",
                 false, "data", "metadata"), CheckpointTag.FromByStreamPosition(0, "", 1, "account-02", 0, 500),
             _subscriptionId, 3));
     _bus.Publish(
         new EventReaderSubscriptionMessage.PartitionEofReached(
             _subscriptionId, CheckpointTag.FromByStreamPosition(0, "", 1, "account-02", int.MaxValue, 500),
             "account-01", 4));
 }
        protected override void When()
        {
            //projection subscribes here
            _eventId = Guid.NewGuid();
            _consumer.HandledMessages.Clear();

            var tag0 = CheckpointTag.FromByStreamPosition(0, "catalog", 0, "account-00", 0, long.MinValue);

            _bus.Publish(
                EventReaderSubscriptionMessage.CommittedEventReceived.Sample(
                    new ResolvedEvent(
                        "account-00", 0, "account-00", 0, false, new TFPos(120, 110), _eventId,
                        "handle_this_type", false, "data", "metadata"), tag0, _subscriptionId, 0));
            _bus.Publish(
                new EventReaderSubscriptionMessage.PartitionEofReached(
                    _subscriptionId, tag0,
                    "account-00", 1));


            var tag1 = CheckpointTag.FromByStreamPosition(0, "catalog", 1, "account-01", 0, long.MinValue);

            _bus.Publish(
                EventReaderSubscriptionMessage.CommittedEventReceived.Sample(
                    new ResolvedEvent(
                        "account-01", 0, "account-01", 0, false, new TFPos(220, 210), _eventId,
                        "handle_this_type", false, "data", "metadata"), tag1, _subscriptionId, 2));
            _bus.Publish(
                new EventReaderSubscriptionMessage.PartitionEofReached(
                    _subscriptionId, tag1,
                    "account-01", 3));
        }
            protected override IEnumerable <WhenStep> When()
            {
                var fromZeroPosition = CheckpointTag.FromByStreamPosition(0, "", -1, null, -1, 10000);

                yield return
                    (new ReaderSubscriptionManagement.Subscribe(
                         _subscriptionId,
                         fromZeroPosition,
                         _readerStrategy,
                         _readerSubscriptionOptions));

                yield return
                    (new ReaderSubscriptionManagement.SpoolStreamReadingCore(_subscriptionId,
                                                                             "test-stream",
                                                                             0,
                                                                             10000));

                yield return(Yield);

                Assert.AreEqual(
                    2,
                    HandledMessages.OfType <EventReaderSubscriptionMessage.CommittedEventReceived>().Count());

                yield return
                    (new ReaderSubscriptionManagement.SpoolStreamReadingCore(_subscriptionId,
                                                                             "test-stream2",
                                                                             1,
                                                                             10000));
            }
            protected override IEnumerable <WhenStep> When()
            {
                var fromZeroPosition = CheckpointTag.FromByStreamPosition(0, "", -1, null, -1, 100000);

                yield return
                    (new ReaderSubscriptionManagement.Subscribe(
                         _subscriptionId, fromZeroPosition, _readerStrategy, _readerSubscriptionOptions));
            }
Beispiel #6
0
 protected override void When()
 {
     //projection subscribes here
     _eventId = Guid.NewGuid();
     _consumer.HandledMessages.Clear();
     _bus.Publish(
         new EventReaderSubscriptionMessage.EofReached(
             _subscriptionId, CheckpointTag.FromByStreamPosition(0, "catalog", -1, null, -1, long.MinValue), 0));
 }
Beispiel #7
0
		public void by_stream_based_checkpoint_tag_zero() {
			CheckpointTag tag = CheckpointTag.FromByStreamPosition(0, "catalog", -1, null, -1, 12345);
			byte[] bytes = tag.ToJsonBytes(_version);
			string instring = Helper.UTF8NoBom.GetString(bytes);
			Console.WriteLine(instring);

			CheckpointTag back = instring.ParseCheckpointTagJson();
			Assert.AreEqual(tag, back);
		}
            protected override IEnumerable <WhenStep> When()
            {
                var fromZeroPosition = CheckpointTag.FromByStreamPosition(0, "catalog", -1, null, -1, 1000);

                yield return
                    (new WhenStep(
                         new ReaderSubscriptionManagement.Subscribe(
                             _subscriptionId, fromZeroPosition, _readerStrategy, _readerSubscriptionOptions),
                         CreateWriteEvent("test-stream4", "type1", "{Data: 8}"),
                         CreateWriteEvent("catalog", "$>", "0@test-stream4")));
            }
Beispiel #9
0
        public void data_and_catalog_position_should_not_overflow()
        {
            var checkpointTag =
                CheckpointTag.FromByStreamPosition(1, "catalog", 9876543210L, "data", 9876543211L, 9876543212L);
            var json = checkpointTag.ToJsonString();

            var jsonReader            = new JsonTextReader(new StringReader(json));
            var checkpointTagFromJson = CheckpointTag.FromJson(jsonReader, new ProjectionVersion(0, 0, 0));

            Assert.AreEqual(9876543210L, checkpointTagFromJson.Tag.CatalogPosition);
            Assert.AreEqual(9876543211L, checkpointTagFromJson.Tag.DataPosition);
        }
Beispiel #10
0
            protected override IEnumerable <WhenStep> When()
            {
                var fromZeroPosition = CheckpointTag.FromByStreamPosition(0, "", -1, null, -1, 10000);

                yield return
                    (new ReaderSubscriptionManagement.Subscribe(
                         _subscriptionId, fromZeroPosition, _readerStrategy, _readerSubscriptionOptions));

                yield return
                    (new WhenStep(
                         new ReaderSubscriptionManagement.SpoolStreamReading(_subscriptionId, Guid.NewGuid(), "test-stream", 0, 10000),
                         new ReaderSubscriptionManagement.SpoolStreamReading(_subscriptionId, Guid.NewGuid(), "test-stream2", 1, 10000)));
            }
Beispiel #11
0
        protected override void When()
        {
            var tag0 = CheckpointTag.FromByStreamPosition(0, "", 0, null, -1, 10000);
            var tag1 = CheckpointTag.FromByStreamPosition(0, "", 1, null, -1, 10000);

            _bus.Publish(
                EventReaderSubscriptionMessage.CommittedEventReceived.Sample(
                    new ResolvedEvent(
                        "catalog", 0, "catalog", 0, false, new TFPos(120, 110), _eventId, "$@", false, "test-stream", ""),
                    tag0, _subscriptionId, 0));
            _bus.Publish(
                EventReaderSubscriptionMessage.CommittedEventReceived.Sample(
                    new ResolvedEvent(
                        "catalog", 1, "catalog", 1, false, new TFPos(220, 210), Guid.NewGuid(), "$@", false,
                        "test-stream2", ""), tag1, _subscriptionId, 1));
        }