public void cannot_handle_repeated_read_events_completed()
        {
            var correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last()
                                .CorrelationId;

            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "stream", 100, 100, ReadStreamResult.Success,
                    new[] {
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        10, 50, Guid.NewGuid(), Guid.NewGuid(), 50, 0, "stream", ExpectedVersion.Any,
                        DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type", new byte[0], new byte[0]))
            }, null, false, "", 11, 10, true, 100));
            Assert.AreEqual(1, HandledMessages.OfType <ReaderSubscriptionMessage.Faulted>().Count());
        }
Exemplo n.º 2
0
        public new void When()
        {
            _distibutionPointCorrelationId = Guid.NewGuid();
            _fakeTimeProvider = new FakeTimeProvider();
            _edp = new StreamEventReader(_bus, _distibutionPointCorrelationId, null, "stream", 10, _fakeTimeProvider,
                                         false,
                                         produceStreamDeletes: false);
            _edp.Resume();
            _firstEventId  = Guid.NewGuid();
            _secondEventId = Guid.NewGuid();
            var correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last()
                                .CorrelationId;

            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "stream", 100, 100, ReadStreamResult.Success,
                    new[] {
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        10, 50, Guid.NewGuid(), _firstEventId, 50, 0, "stream", ExpectedVersion.Any,
                        DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type1", new byte[] { 1 }, new byte[] { 2 })),
                ResolvedEvent.ForUnresolvedEvent(
                    new EventRecord(
                        11, 100, Guid.NewGuid(), _secondEventId, 100, 0, "stream", ExpectedVersion.Any,
                        DateTime.UtcNow,
                        PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                        "event_type2", new byte[] { 3 }, new byte[] { 4 }))
            }, null, false, "", 12, 11, true, 200));
            correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>().Last()
                            .CorrelationId;
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "stream", 100, 100, ReadStreamResult.Success,
                    new ResolvedEvent[] { }, null, false, "", 12, 11, true, 400));
            _fakeTimeProvider.AddToUtcTime(TimeSpan.FromMilliseconds(500));
            correlationId = ((ClientMessage.ReadStreamEventsForward)(_consumer.HandledMessages
                                                                     .OfType <AwakeServiceMessage.SubscribeAwake>().Last().ReplyWithMessage)).CorrelationId;
            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, "stream", 100, 100, ReadStreamResult.Success,
                    new ResolvedEvent[] { }, null, false, "", 12, 11, true, 400));
        }
Exemplo n.º 3
0
 public new void When()
 {
     _distibutionPointCorrelationId = Guid.NewGuid();
     _edp = new StreamEventReader(_bus, _distibutionPointCorrelationId, null, "stream", 0, new RealTimeProvider(), false,
                                  produceStreamDeletes: false);
     _edp.Resume();
     _edp.Handle(
         new ClientMessage.ReadStreamEventsForwardCompleted(
             _distibutionPointCorrelationId, "stream", 100, 100,
             ReadStreamResult.NoStream, new ResolvedEvent[0], null, false, "", -1, ExpectedVersion.NoStream, true, 200));
 }
Exemplo n.º 4
0
        private void HandleEvents(string stream, long[] eventNumbers)
        {
            string eventType            = "event_type";
            List <ResolvedEvent> events = new List <ResolvedEvent>();

            foreach (long eventNumber in eventNumbers)
            {
                events.Add(
                    ResolvedEvent.ForUnresolvedEvent(
                        new EventRecord(
                            eventNumber, 50 * (eventNumber + 1), Guid.NewGuid(), Guid.NewGuid(), 50 * (eventNumber + 1),
                            0, stream, ExpectedVersion.Any, DateTime.UtcNow,
                            PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                            eventType, new byte[] { 0 }, new byte[] { 0 }
                            )
                        )
                    );
            }

            long start, end;

            if (eventNumbers.Length > 0)
            {
                start = eventNumbers[0];
                end   = eventNumbers[eventNumbers.Length - 1];
            }
            else
            {
                start = _fromSequenceNumber;
                end   = _fromSequenceNumber;
            }

            var correlationId = _consumer.HandledMessages.OfType <ClientMessage.ReadStreamEventsForward>()
                                .Last(x => x.EventStreamId == stream).CorrelationId;

            _edp.Handle(
                new ClientMessage.ReadStreamEventsForwardCompleted(
                    correlationId, stream, start, 100, ReadStreamResult.Success, events.ToArray(), null, false, "",
                    start + 1, end, true, 200)
                );
        }
Exemplo n.º 5
0
 public void can_handle_read_events_completed()
 {
     _edp.Handle(
         new ClientMessage.ReadStreamEventsForwardCompleted(
             _distibutionPointCorrelationId, "stream", 100, 100, ReadStreamResult.Success,
             new[]
     {
         ResolvedEvent.ForUnresolvedEvent(new EventRecord(
                                              10, 50, Guid.NewGuid(), Guid.NewGuid(), 50, 0, "stream", ExpectedVersion.Any, DateTime.UtcNow,
                                              PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                                              "event_type", new byte[0], new byte[0]), 0)
     }, null, false, "", 11, 10, true, 100));
 }
 public new void When()
 {
     //_publishWithCorrelationId = Guid.NewGuid();
     _distibutionPointCorrelationId = Guid.NewGuid();
     _fakeTimeProvider = new FakeTimeProvider();
     _edp = new StreamEventReader(
         _ioDispatcher, _bus, _distibutionPointCorrelationId, null, "stream", 10, _fakeTimeProvider, false,
         produceStreamDeletes: false);
     _edp.Resume();
     _firstEventId  = Guid.NewGuid();
     _secondEventId = Guid.NewGuid();
     _edp.Handle(
         new ClientMessage.ReadStreamEventsForwardCompleted(
             _distibutionPointCorrelationId, "stream", 100, 100, ReadStreamResult.Success,
             new[]
     {
         new ResolvedEvent(
             new EventRecord(
                 10, 50, Guid.NewGuid(), _firstEventId, 50, 0, "stream", ExpectedVersion.Any, DateTime.UtcNow,
                 PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                 "event_type1", new byte[] { 1 }, new byte[] { 2 }), null),
         new ResolvedEvent(
             new EventRecord(
                 11, 100, Guid.NewGuid(), _secondEventId, 100, 0, "stream", ExpectedVersion.Any,
                 DateTime.UtcNow,
                 PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                 "event_type2", new byte[] { 3 }, new byte[] { 4 }), null)
     }, null, false, "", 12, 11, true, 200));
     _edp.Handle(
         new ClientMessage.ReadStreamEventsForwardCompleted(
             _distibutionPointCorrelationId, "stream", 100, 100, ReadStreamResult.Success,
             new ResolvedEvent[] { }, null, false, "", 12, 11, true, 400));
     _fakeTimeProvider.AddTime(TimeSpan.FromMilliseconds(500));
     _edp.Handle(
         new ClientMessage.ReadStreamEventsForwardCompleted(
             _distibutionPointCorrelationId, "stream", 100, 100, ReadStreamResult.Success,
             new ResolvedEvent[] { }, null, false, "", 12, 11, true, 400));
 }
Exemplo n.º 7
0
 public new void When()
 {
     _streamEventReader.Handle(
         new ClientMessage.ReadStreamEventsForwardCompleted(
             _distibutionPointCorrelationId, _streamId, 100, 100, ReadStreamResult.Success,
             new[]
     {
         ResolvedEvent.ForUnresolvedEvent(
             new EventRecord(
                 10, 50, Guid.NewGuid(), _firstEventId, 50, 0, _streamId, ExpectedVersion.Any, DateTime.UtcNow,
                 PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd,
                 "event_type1", new byte[] { 1 }, new byte[] { 2 })),
         ResolvedEvent.ForUnresolvedEvent(
             new EventRecord(
                 11, 100, Guid.NewGuid(), _secondEventId, 100, 0, _streamId, ExpectedVersion.Any,
                 DateTime.UtcNow,
                 PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd | PrepareFlags.IsJson,
                 "event_type2", new byte[] { 3 }, new byte[] { 4 }))
     }, null, false, "", 12, 11, true, 200));
 }
 public void handle_read_events_completed_throws()
 {
     _edp.Handle(
         new ClientMessage.ReadStreamEventsForwardCompleted(
             _distibutionPointCorrelationId, "stream", 100, 100, ReadStreamResult.Success, new ResolvedEvent[0], null, false, "", -1, 4, true, 100));
 }