Exemple #1
0
        private EmittedEventEnvelope[] CreateResultUpdatedEvents(string partition, string projectionResult, CheckpointTag at)
        {
            var streamId           = _namesBuilder.MakePartitionResultStreamName(partition);
            var allResultsStreamId = _namesBuilder.GetResultStreamName();

            if (string.IsNullOrEmpty(partition))
            {
                var result =
                    new EmittedEventEnvelope(
                        projectionResult == null
                            ? new EmittedDataEvent(
                            streamId, Guid.NewGuid(), "ResultRemoved", true, null, null, at, null)
                            : new EmittedDataEvent(
                            streamId, Guid.NewGuid(), "Result", true, projectionResult, null, at, null),
                        _resultStreamMetadata);

                return(new[] { result });
            }
            else
            {
                var linkTo         = new EmittedLinkTo(allResultsStreamId, Guid.NewGuid(), streamId, at, null);
                var linkToEnvelope = new EmittedEventEnvelope(linkTo, _resultStreamMetadata);
                var result         =
                    new EmittedEventEnvelope(
                        projectionResult == null
                            ? new EmittedDataEvent(
                            streamId, Guid.NewGuid(), "ResultRemoved", true, null, null, at, null,
                            linkTo.SetTargetEventNumber)
                            : new EmittedDataEvent(
                            streamId, Guid.NewGuid(), "Result", true, projectionResult, null, at, null,
                            linkTo.SetTargetEventNumber), _resultStreamMetadata);
                return(new[] { result, linkToEnvelope });
            }
        }
 private EmittedEventEnvelope[] CreateResultUpdatedEvents(string partition, string projectionResult, CheckpointTag at)
 {
     var streamId = _namesBuilder.MakePartitionResultStreamName(partition);
     var allResultsStreamId = _namesBuilder.GetResultStreamName();
     if (string.IsNullOrEmpty(partition))
     {
         var result =
             new EmittedEventEnvelope(
                 projectionResult == null
                     ? new EmittedDataEvent(
                         streamId, Guid.NewGuid(), "ResultRemoved", true, null, null, at, null)
                     : new EmittedDataEvent(
                         streamId, Guid.NewGuid(), "Result", true, projectionResult, null, at, null),
                 _resultStreamMetadata);
         
         return new[] {result};
     }
     else
     {
         var linkTo = new EmittedLinkTo(allResultsStreamId, Guid.NewGuid(), streamId, at, null);
         var linkToEnvelope = new EmittedEventEnvelope(linkTo, _resultStreamMetadata);
         var result =
             new EmittedEventEnvelope(
                 projectionResult == null
                     ? new EmittedDataEvent(
                         streamId, Guid.NewGuid(), "ResultRemoved", true, null, null, at, null,
                         linkTo.SetTargetEventNumber)
                     : new EmittedDataEvent(
                         streamId, Guid.NewGuid(), "Result", true, projectionResult, null, at, null,
                         linkTo.SetTargetEventNumber), _resultStreamMetadata);
         return new[] {result, linkToEnvelope};
     }
 }
        public void replies_with_await_message_on_write_completed_if_not_yet_ready()
        {
            var linkTo = new EmittedLinkTo(
                "test_stream", Guid.NewGuid(), "other_stream", CheckpointTag.FromPosition(0, 1100, 1000), null);
            _stream.EmitEvents(new[] {linkTo});
            _stream.Handle(new CoreProjectionProcessingMessage.EmittedStreamWriteCompleted("one_more_stream"));

            Assert.AreEqual(2, _readyHandler.HandledStreamAwaitingMessage.Count);
            Assert.AreEqual("test_stream", _readyHandler.HandledStreamAwaitingMessage[0].StreamId);
            Assert.AreEqual("test_stream", _readyHandler.HandledStreamAwaitingMessage[1].StreamId);
        }
        public void processes_write_on_write_completed_if_ready()
        {
            var linkTo = new EmittedLinkTo(
                "test_stream", Guid.NewGuid(), "other_stream", CheckpointTag.FromPosition(0, 1100, 1000), null);
            _stream.EmitEvents(new[] {linkTo});
            linkTo.SetTargetEventNumber(1);
            _stream.Handle(new CoreProjectionProcessingMessage.EmittedStreamWriteCompleted("other_stream"));

            Assert.AreEqual(1, _readyHandler.HandledStreamAwaitingMessage.Count);
            Assert.AreEqual(
                1,
                _consumer.HandledMessages.OfType<ClientMessage.WriteEvents>()
                    .OfEventType(SystemEventTypes.LinkTo)
                    .Count());
        }