public new void When()
        {
            _ab12Tag = new Dictionary<string, int> { { "a", 1 }, { "b", 2 } };
            _abStreams = new[] { "a", "b" };

            _publishWithCorrelationId = Guid.NewGuid();
            _distibutionPointCorrelationId = Guid.NewGuid();
            _edp = new MultiStreamEventReader(
                _ioDispatcher, _bus, _distibutionPointCorrelationId, null, 0, _abStreams, _ab12Tag, false,
                new RealTimeProvider());
            _edp.Resume();
            _firstEventId = Guid.NewGuid();
            _secondEventId = Guid.NewGuid();
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "a", 100, 100, ReadStreamResult.Success, 
                    new[]
                    {
                        new ResolvedEvent( 
                            new EventRecord(
                                1, 50, Guid.NewGuid(), _firstEventId, 50, 0, "a", ExpectedVersion.Any, DateTime.UtcNow,
                                PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                                "event_type1", new byte[] {1}, new byte[] {2}), null),
                        new ResolvedEvent( 
                            new EventRecord(
                                2, 100, Guid.NewGuid(), _secondEventId, 100, 0, "a", ExpectedVersion.Any, DateTime.UtcNow,
                                PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                                "event_type2", new byte[] {3}, new byte[] {4}), null)
                    }, null, false, "", 3, 4, false, 200));
        }
        public new void When()
        {
            _ab12Tag = new Dictionary <string, int> {
                { "a", 1 }, { "b", 2 }
            };
            _abStreams = new[] { "a", "b" };

            _distibutionPointCorrelationId = Guid.NewGuid();
            _edp = new MultiStreamEventReader(
                _ioDispatcher, _bus, _distibutionPointCorrelationId, null, 0, _abStreams, _ab12Tag, false,
                new RealTimeProvider());
            _edp.Resume();
            _firstEventId  = Guid.NewGuid();
            _secondEventId = Guid.NewGuid();
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "a", 100, 100, ReadStreamResult.Success,
                    new[]
            {
                new ResolvedEvent(
                    new EventRecord(
                        1, 50, Guid.NewGuid(), _firstEventId, 50, 0, "a", ExpectedVersion.Any, DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type1", new byte[] { 1 }, new byte[] { 2 }), null),
                new ResolvedEvent(
                    new EventRecord(
                        2, 100, Guid.NewGuid(), _secondEventId, 100, 0, "a", ExpectedVersion.Any, DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type2", new byte[] { 3 }, new byte[] { 4 }), null)
            }, null, false, "", 3, 4, false, 200));
        }
예제 #3
0
        public new void When()
        {
            _ab12Tag = new Dictionary <string, long> {
                { "a", 1 }, { "b", 2 }
            };
            _abStreams = new[] { "a", "b" };

            _distibutionPointCorrelationId = Guid.NewGuid();
            _edp = new MultiStreamEventReader(
                _ioDispatcher, _bus, _distibutionPointCorrelationId, null, 0, _abStreams, _ab12Tag, false,
                new RealTimeProvider());
            _edp.Resume();
            _firstEventId  = Guid.NewGuid();
            _secondEventId = Guid.NewGuid();
            _thirdEventId  = Guid.NewGuid();
            _fourthEventId = Guid.NewGuid();
            var correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last(x => x.EventStreamId == "a").CorrelationId;

            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "a", 100, 100, ReadStreamResult.Success,
                    new[]
            {
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        1, 50, Guid.NewGuid(), _firstEventId, 50, 0, "a", ExpectedVersion.Any, DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type1", new byte[] { 1 }, new byte[] { 2 })),
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        2, 100, Guid.NewGuid(), _secondEventId, 100, 0, "a", ExpectedVersion.Any, DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type2", new byte[] { 3 }, new byte[] { 4 }))
            }, null, false, "", 3, 2, true, 200));
            correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last(x => x.EventStreamId == "b").CorrelationId;
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "b", 100, 100, ReadStreamResult.Success,
                    new[]
            {
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        2, 150, Guid.NewGuid(), _thirdEventId, 150, 0, "b", ExpectedVersion.Any, DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type1", new byte[] { 1 }, new byte[] { 2 })),
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        3, 200, Guid.NewGuid(), _fourthEventId, 200, 0, "b", ExpectedVersion.Any, DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type2", new byte[] { 3 }, new byte[] { 4 }))
            }, null, false, "", 4, 3, true, 200));
            _edp.Pause();
            correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last(x => x.EventStreamId == "a").CorrelationId;
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "a", 100, 100, ReadStreamResult.Success, new ResolvedEvent[] { }, null, false, "", 3, 2, true, 400));
        }
        public void When()
        {
            _ab12Tag = new Dictionary<string, int> { { "a", 1 }, { "b", 2 } };
            _abStreams = new[] { "a", "b" };

            _publishWithCorrelationId = Guid.NewGuid();
            _distibutionPointCorrelationId = Guid.NewGuid();
            _edp = new MultiStreamEventReader(_bus, _distibutionPointCorrelationId, _abStreams, _ab12Tag, false, new RealTimeProvider());
        }
예제 #5
0
        public new void When()
        {
            _distibutionPointCorrelationId = Guid.NewGuid();

            _edp = new MultiStreamEventReader(
                _ioDispatcher, _bus, _distibutionPointCorrelationId, null, 0, _streamNames, _streamPositions, false,
                new RealTimeProvider());

            _edp.Resume();
        }
예제 #6
0
        public new void When()
        {
            _ab12Tag = new Dictionary<string, int> {{"a", 1}, {"b", 2}};
            _abStreams = new[] {"a", "b"};

            _distibutionPointCorrelationId = Guid.NewGuid();
            _edp = new MultiStreamEventReader(
                _bus, _distibutionPointCorrelationId, null, 0, _abStreams, _ab12Tag, false, new RealTimeProvider());

            _edp.Resume();
        }
        public new void When()
        {
            _ab12Tag = new Dictionary <string, long> {
                { "a", 1 }, { "b", 2 }
            };
            _abStreams = new[] { "a", "b" };

            _distibutionPointCorrelationId = Guid.NewGuid();
            _fakeTimeProvider = new FakeTimeProvider();
            _edp = new MultiStreamEventReader(
                _ioDispatcher, _bus, _distibutionPointCorrelationId, null, 0, _abStreams, _ab12Tag, false,
                _fakeTimeProvider);
            _edp.Resume();
            _firstEventId  = Guid.NewGuid();
            _secondEventId = Guid.NewGuid();
            var correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last(x => x.EventStreamId == "a").CorrelationId;

            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "a", 100, 100, ReadStreamResult.Success,
                    new[]
            {
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        1, 50, Guid.NewGuid(), _firstEventId, 50, 0, "a", ExpectedVersion.Any, _fakeTimeProvider.Now,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type1", new byte[] { 1 }, new byte[] { 2 })),
            }, null, false, "", 2, 1, true, 200));
            correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last(x => x.EventStreamId == "b").CorrelationId;
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "b", 100, 100, ReadStreamResult.Success,
                    new[]
            {
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        2, 100, Guid.NewGuid(), _secondEventId, 100, 0, "b", ExpectedVersion.Any, _fakeTimeProvider.Now,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type1", new byte[] { 1 }, new byte[] { 2 })),
            }, null, false, "", 3, 2, true, 200));
            correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last(x => x.EventStreamId == "a").CorrelationId;
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "a", 100, 100, ReadStreamResult.Success, new ResolvedEvent[] { }, null, false, "", 2, 1, true, 400));
            correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last(x => x.EventStreamId == "b").CorrelationId;
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "b", 100, 100, ReadStreamResult.Success, new ResolvedEvent[] { }, null, false, "", 3, 2, true, 400));
            _fakeTimeProvider.AddTime(TimeSpan.FromMilliseconds(500));
            correlationId = ((ClientMessage.ReadStreamEventsForward)(_consumer.HandledMessages.OfType <AwakeServiceMessage.SubscribeAwake>().Last().ReplyWithMessage)).CorrelationId;
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "a", 100, 100, ReadStreamResult.Success, new ResolvedEvent[] { }, null, false, "", 2, 1, true, 600));
        }
예제 #8
0
        public new void When()
        {
            _ab12Tag = new Dictionary<string, int> {{"a", 1}, {"b", 2}};
            _abStreams = new[] {"a", "b"};

            _distibutionPointCorrelationId = Guid.NewGuid();
            _edp = new MultiStreamEventReader(
                _ioDispatcher, _bus, _distibutionPointCorrelationId, null, 0, _abStreams, _ab12Tag, false,
                new RealTimeProvider());

            _edp.Resume();
        }
        public new void When()
        {
            _ab12Tag = new Dictionary <string, int> {
                { "a", 1 }, { "b", 2 }
            };
            _abStreams = new[] { "a", "b" };

            _distibutionPointCorrelationId = Guid.NewGuid();
            _fakeTimeProvider = new FakeTimeProvider();
            _edp = new MultiStreamEventReader(
                _bus, _distibutionPointCorrelationId, null, 0, _abStreams, _ab12Tag, false, _fakeTimeProvider);
            _edp.Resume();
            _firstEventId  = Guid.NewGuid();
            _secondEventId = Guid.NewGuid();
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "a", 100, 100, ReadStreamResult.Success,
                    new[]
            {
                new ResolvedEvent(
                    new EventRecord(
                        1, 50, Guid.NewGuid(), _firstEventId, 50, 0, "a", ExpectedVersion.Any, _fakeTimeProvider.Now,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type1", new byte[] { 1 }, new byte[] { 2 }), null),
            }, null, false, "", 2, 1, true, 200));
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "b", 100, 100, ReadStreamResult.Success,
                    new[]
            {
                new ResolvedEvent(
                    new EventRecord(
                        2, 100, Guid.NewGuid(), _secondEventId, 100, 0, "b", ExpectedVersion.Any, _fakeTimeProvider.Now,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type1", new byte[] { 1 }, new byte[] { 2 }), null),
            }, null, false, "", 3, 2, true, 200));
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "a", 100, 100, ReadStreamResult.Success, new ResolvedEvent[] { }, null, false, "", 2, 1, true, 400));
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "b", 100, 100, ReadStreamResult.Success, new ResolvedEvent[] { }, null, false, "", 3, 2, true, 400));
            _fakeTimeProvider.AddTime(TimeSpan.FromMilliseconds(500));
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "a", 100, 100, ReadStreamResult.Success, new ResolvedEvent[] { }, null, false, "", 2, 1, true, 600));
        }
        public new void When()
        {
            _ab12Tag = new Dictionary<string, int> {{"a", 1}, {"b", 2}};
            _abStreams = new[] {"a", "b"};

            _distibutionPointCorrelationId = Guid.NewGuid();
            _fakeTimeProvider = new FakeTimeProvider();
            _edp = new MultiStreamEventReader(
                _ioDispatcher, _bus, _distibutionPointCorrelationId, null, 0, _abStreams, _ab12Tag, false,
                _fakeTimeProvider);
            _edp.Resume();
            _firstEventId = Guid.NewGuid();
            _secondEventId = Guid.NewGuid();
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "a", 100, 100, ReadStreamResult.Success, 
                    new[]
                        {
                            ResolvedEvent.ForUnresolvedEvent(
                        new EventRecord(
                            1, 50, Guid.NewGuid(), _firstEventId, 50, 0, "a", ExpectedVersion.Any, _fakeTimeProvider.Now,
                            PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                            "event_type1", new byte[] {1}, new byte[] {2})),
                        }, null, false, "", 2, 1, true, 200));
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "b", 100, 100, ReadStreamResult.Success, 
                    new[]
                        {
                            ResolvedEvent.ForUnresolvedEvent(
                        new EventRecord(
                            2, 100, Guid.NewGuid(), _secondEventId, 100, 0, "b", ExpectedVersion.Any, _fakeTimeProvider.Now,
                            PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                            "event_type1", new byte[] {1}, new byte[] {2})),
                        }, null, false, "", 3, 2, true, 200));
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "a", 100, 100, ReadStreamResult.Success, new ResolvedEvent[] { }, null, false, "", 2, 1, true, 400));
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "b", 100, 100, ReadStreamResult.Success, new ResolvedEvent[] { }, null, false, "", 3, 2, true, 400));
            _fakeTimeProvider.AddTime(TimeSpan.FromMilliseconds(500));
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    _distibutionPointCorrelationId, "a", 100, 100, ReadStreamResult.Success, new ResolvedEvent[] { }, null, false, "", 2, 1, true, 600));
        }
 public void it_can_be_created()
 {
     var edp = new MultiStreamEventReader(_bus, Guid.NewGuid(), _abStreams, _ab12Tag, false, _timeProvider);
 }
        public new void When()
        {
            _ab12Tag = new Dictionary <string, long> {
                { "a", 1 }, { "b", 2 }
            };
            _abStreams = new[] { "a", "b" };
            _distibutionPointCorrelationId = Guid.NewGuid();
            _eventReader = new MultiStreamEventReader(
                _ioDispatcher, _bus, _distibutionPointCorrelationId, null, 0, _abStreams, _ab12Tag, false,
                new RealTimeProvider());
            _eventReader.Resume();
            var correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>()
                                .Last(x => x.EventStreamId == "a").CorrelationId;

            _eventReader.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "a", 100, 100, ReadStreamResult.Success,
                    new[] {
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        1, 50, Guid.NewGuid(), Guid.NewGuid(), 50, 0, "a", ExpectedVersion.Any, DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd |
                        PrepareFlags.IsJson,
                        "event_type1", new byte[] { 1 }, new byte[] { 2 })),
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        2, 150, Guid.NewGuid(), Guid.NewGuid(), 150, 0, "a", ExpectedVersion.Any,
                        DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type2", new byte[] { 3 }, new byte[] { 4 }))
            }, null, false, "", 3, 2, true, 200));
            //timeout follows
            _eventReader.Handle(
                new ProjectionManagementMessage.Internal.ReadTimeout(correlationId, "a"));
            correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>()
                            .Last(x => x.EventStreamId == "b").CorrelationId;
            _eventReader.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "b", 100, 100, ReadStreamResult.Success,
                    new[] {
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        2, 100, Guid.NewGuid(), Guid.NewGuid(), 100, 0, "b", ExpectedVersion.Any,
                        DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type1", new byte[] { 1 }, new byte[] { 2 })),
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        3, 200, Guid.NewGuid(), Guid.NewGuid(), 200, 0, "b", ExpectedVersion.Any,
                        DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type2", new byte[] { 3 }, new byte[] { 4 }))
            }, null, false, "", 4, 3, true, 200));
            //timeout follows
            _eventReader.Handle(
                new ProjectionManagementMessage.Internal.ReadTimeout(correlationId, "b"));
            correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>()
                            .Last(x => x.EventStreamId == "a").CorrelationId;
            _consumer.HandledMessages.Clear();
            //timeout before read completes
            _eventReader.Handle(
                new ProjectionManagementMessage.Internal.ReadTimeout(correlationId, "a"));
            _eventReader.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "a", 100, 100, ReadStreamResult.Success,
                    new[] {
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        3, 300, Guid.NewGuid(), Guid.NewGuid(), 300, 0, "a", ExpectedVersion.Any,
                        DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd |
                        PrepareFlags.IsJson,
                        "event_type1", new byte[] { 4 }, new byte[] { 6 })),
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        4, 400, Guid.NewGuid(), Guid.NewGuid(), 400, 0, "a", ExpectedVersion.Any,
                        DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type2", new byte[] { 6 }, new byte[] { 8 }))
            }, null, false, "", 3, 2, true, 200));
        }
 public void empty_event_reader_id_throws_argument_exception()
 {
     var edp = new MultiStreamEventReader(_bus, Guid.Empty, _abStreams, _ab12Tag, false, _timeProvider);
 }
 public void null_streams_throws_argument_null_exception()
 {
     var edp = new MultiStreamEventReader(_bus, Guid.NewGuid(), null, _ab12Tag, false, _timeProvider);
 }
 public void null_time_provider_throws_argument_null_exception()
 {
     var edp = new MultiStreamEventReader(_bus, Guid.NewGuid(), _abStreams, _ab12Tag, false, null);
 }
 public void empty_streams_throws_argument_exception()
 {
     var edp = new MultiStreamEventReader(_bus, Guid.NewGuid(), new string[0], _ab12Tag, false, _timeProvider);
 }
 public void null_publisher_throws_argument_null_exception()
 {
     var edp = new MultiStreamEventReader(null, Guid.NewGuid(), _abStreams, _ab12Tag, false, _timeProvider);
 }
 public void invalid_from_tag_throws_argument_exception()
 {
     var edp = new MultiStreamEventReader(
         _bus, Guid.NewGuid(), _abStreams,
         new Dictionary<string, int> {{"a", 1}, {"c", 2}}, false, _timeProvider);
 }