public void FindProcessAndCreateMessagingStepBeforeStreamFirstReadEvent()
        {
            var trackingContext = new TrackingContext {
                ProcessActivityId = ActivityId.NewActivityId()
            };

            using (var stream = new TrackingStream(new StringStream("some-content")))
            {
                MessageMock.Object.BodyPart.Data = stream;
                MessageMock.Setup(m => m.GetProperty(BtsProperties.OutboundTransportLocation)).Returns("outbound-transport-location");
                MessageMock.Setup(m => m.GetProperty(TrackingProperties.ProcessActivityId)).Returns(trackingContext.ProcessActivityId);
                MessageMock.Setup(m => m.GetProperty(TrackingProperties.MessagingStepActivityId)).Returns(trackingContext.MessagingStepActivityId);

                var sut = ActivityTracker.Create(new MicroComponent.ActivityTracker.Context(PipelineContextMock.Object, MessageMock.Object, ActivityTrackingModes.Step));
                sut.TrackActivity();

                ActivityFactory.Verify(
                    af => af.CreateProcess(It.IsAny <IBaseMessage>(), It.IsAny <string>()),
                    Times.Never());
                ActivityFactory.Verify(
                    af => af.FindProcess(It.Is <TrackingContext>(c => c.ProcessActivityId == trackingContext.ProcessActivityId)),
                    Times.Once());
                ActivityFactory.Verify(
                    af => af.CreateMessagingStep(It.IsAny <IBaseMessage>()),
                    Times.Once());
                ActivityFactory.Verify(
                    af => af.FindMessagingStep(It.IsAny <TrackingContext>()),
                    Times.Never());
            }
        }
예제 #2
0
        public void TrackActivityWhenBatchTrackingContextIsNull()
        {
            var sut = BatchReleaseProcessActivityTracker.Create(PipelineContextMock.Object, MessageMock.Object);

            sut.TrackActivity(null);

            ActivityFactory.Verify(af => af.CreateProcess(It.IsAny <IBaseMessage>(), It.IsAny <string>()), Times.Never);
            ActivityFactory.Verify(af => af.FindProcess(It.IsAny <string>()), Times.Never);

            ProcessMock.Verify(p => p.TrackActivity(), Times.Never);
            ProcessMock.Verify(p => p.AddSteps(It.IsAny <IEnumerable <string> >()), Times.Never);
        }
예제 #3
0
        public void TrackActivityWithoutAmbientProcessActivity()
        {
            var batchTrackingContext = new BatchTrackingContext {
                MessagingStepActivityIdList = new[] { ActivityId.NewActivityId(), ActivityId.NewActivityId(), ActivityId.NewActivityId() }
            };

            var sut = BatchReleaseProcessActivityTracker.Create(PipelineContextMock.Object, MessageMock.Object);

            sut.TrackActivity(batchTrackingContext);

            ActivityFactory.Verify(af => af.CreateProcess(MessageMock.Object, It.IsAny <string>()), Times.Once);
            ActivityFactory.Verify(af => af.FindProcess(It.IsAny <string>()), Times.Never);

            ProcessMock.Verify(p => p.TrackActivity(), Times.Once);
            ProcessMock.Verify(
                p => p.AddSteps(
                    It.Is <IEnumerable <string> >(
                        list => list.SequenceEqual(
                            batchTrackingContext.MessagingStepActivityIdList.Append(MessageMock.Object.GetProperty(TrackingProperties.MessagingStepActivityId))))),
                Times.Once);
        }