public void Reads_with_sequence_above_highest_sends_ReadFinished()
        {
            var reader = CreateReader();

            var req = new ReadIndexedProjectionStreamRequest("b", 1000, EventCount.Unlimited);
            reader.Tell(req);
            ExpectMsg<ReadIndexedProjectionStreamFinished>(m => m.RequestID == req.RequestID);
        }
        public void ReadIndexedProjectionStreamRequests_are_forwarded_to_worker()
        {
            var o = new TestContainer(this);

            var req = new ReadIndexedProjectionStreamRequest("a", 1, 1);
            o.Reader.Tell(req);

            o.ReadIndexedProjectionProbe.ExpectMsg<ReadIndexedProjectionStreamRequest>(m => m == req);
        }
        public void Reads_single_event(string streamName, int sequenceToRead)
        {
            var reader = CreateReader();

            var req = new ReadIndexedProjectionStreamRequest(streamName, sequenceToRead, 1);
            reader.Tell(req);

            ExpectMsg<ReadIndexedProjectionStreamResponse>(m => m.RequestID == req.RequestID && m.Event.StreamSequence == sequenceToRead);
            ExpectMsg<ReadIndexedProjectionStreamFinished>(m => m.RequestID == req.RequestID);
        }
        public void Reads_all_events(string streamName, int eventCount)
        {
            var reader = CreateReader();

            var req = new ReadIndexedProjectionStreamRequest(streamName, 1, EventCount.Unlimited);
            reader.Tell(req);

            for (int i = 1; i <= eventCount; i++)
                ExpectMsg<ReadIndexedProjectionStreamResponse>(m => m.RequestID == req.RequestID && m.Event.StreamSequence == i);

            ExpectMsg<ReadIndexedProjectionStreamFinished>(m => m.RequestID == req.RequestID);
        }
 void HandleRequest(ReadIndexedProjectionStreamRequest r)
 {
     var worker = Context.ActorOf(_workerProps);
     worker.Forward(r);
 }
Beispiel #6
0
        void StartReadRequest()
        {
            var maxEvents = _options.EventsPerReadRequest >= 0 ? _options.EventsPerReadRequest : 0;
            var count = Math.Min(_lastSequenceToRead - _currentSequence, maxEvents);

            var readRequest = new ReadIndexedProjectionStreamRequest(_projectionStream, _currentSequence + 1, count);
            _reader.Tell(readRequest);

            _lastRequestId = readRequest.RequestID;
        }
        public void Reads_with_initialsequence_and_counts()
        {
            var reader = CreateReader();

            var req = new ReadIndexedProjectionStreamRequest("c", 7, 3);
            reader.Tell(req);

            ExpectMsg<ReadIndexedProjectionStreamResponse>(m => m.RequestID == req.RequestID && m.Event.StreamSequence == 7);
            ExpectMsg<ReadIndexedProjectionStreamResponse>(m => m.RequestID == req.RequestID && m.Event.StreamSequence == 8);
            ExpectMsg<ReadIndexedProjectionStreamResponse>(m => m.RequestID == req.RequestID && m.Event.StreamSequence == 9);
            ExpectMsg<ReadIndexedProjectionStreamFinished>(m => m.RequestID == req.RequestID);
        }
        public void Reads_with_count_zero_sends_ReadFinished()
        {
            var reader = CreateReader();

            var req = new ReadIndexedProjectionStreamRequest("c", 1, 0);

            reader.Tell(req);
            ExpectMsg<ReadIndexedProjectionStreamFinished>(m => m.RequestID == req.RequestID);
        }
        public void Receives_ReadAborted_on_store_exception()
        {
            var ex = new Exception();
            var store = MockEventStore.ThrowsOnReadStreams(ex);
            var factory = Substitute.For<IPersistedEventFactory>();

            var props = Props.Create<ReadIndexedProjectionStreamWorker>(store, factory);
            var actor = Sys.ActorOf(props);

            var req = new ReadIndexedProjectionStreamRequest("a", 1, EventCount.Unlimited);
            actor.Tell(req);
            ExpectMsg<Aborted>(m => m.RequestID == req.RequestID && m.Exception == ex);
        }
        public void Receives_ReadCancelled_on_cancel_request()
        {
            var reader = CreateReader();

            var req = new ReadIndexedProjectionStreamRequest("a", 1, EventCount.Unlimited);
            reader.Tell(req);
            reader.Tell(new CancelRequest(req.RequestID));

            ExpectMsgEventually<Cancelled>(m => m.RequestID == req.RequestID);
        }