コード例 #1
0
        public void TrackActivityWithAmbientProcessActivity()
        {
            var batchTrackingContext = new BatchTrackingContext {
                MessagingStepActivityIdList = new[] { ActivityId.NewActivityId(), ActivityId.NewActivityId(), ActivityId.NewActivityId() },
                ProcessActivityId           = ActivityId.NewActivityId()
            };

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

            sut.TrackActivity(batchTrackingContext);

            ActivityFactory.Verify(af => af.CreateProcess(It.IsAny <IBaseMessage>(), It.IsAny <string>()), Times.Never());
            // ReSharper disable once ImplicitlyCapturedClosure
            ActivityFactory.Verify(af => af.FindProcess(batchTrackingContext.ProcessActivityId), Times.Once());

            ProcessMock.Verify(p => p.TrackActivity(), Times.Once());
            ProcessMock.Verify(
                p =>
                p.AddSteps(
                    It.Is <IEnumerable <string> >(
                        list =>
                        list.SequenceEqual(
                            batchTrackingContext.MessagingStepActivityIdList
                            .Concat(new[] { MessageMock.Object.GetProperty(TrackingProperties.MessagingStepActivityId) })))),
                Times.Once());
        }
コード例 #2
0
        public void CompleteTrackingOfInboundMessageWithoutProcessAffiliationAfterStreamLastReadEvent()
        {
            using (var stream = new TrackingStream(new StringStream("some-content")))
            {
                MessageMock.Object.BodyPart.Data = stream;

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

                ProcessMock.Verify(
                    p => p.TrackActivity(),
                    Times.Never());
                InitiatingMessagingStepMock.Verify(
                    ms => ms.TrackActivity(It.IsAny <ActivityTrackingModes>(), It.IsAny <TrackingStream>()),
                    Times.Never());
                ProcessMock.Verify(
                    p => p.AddStep(InitiatingMessagingStepMock.Object),
                    Times.Never());
                MessagingStepMock.Verify(
                    ms => ms.TrackActivity(It.IsAny <ActivityTrackingModes>(), It.IsAny <TrackingStream>()),
                    Times.Once());
                ProcessMock.Verify(
                    p => p.AddStep(MessagingStepMock.Object),
                    Times.Never());
            }
        }
コード例 #3
0
        public void CompleteTrackingOfOutboundMessageWithProcessAffiliationAfterStreamLastReadEvent()
        {
            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(ActivityId.NewActivityId());

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

                ProcessMock.Verify(
                    p => p.TrackActivity(),
                    Times.Never());
                InitiatingMessagingStepMock.Verify(
                    ms => ms.TrackActivity(It.IsAny <ActivityTrackingModes>(), It.IsAny <TrackingStream>()),
                    Times.Never());
                ProcessMock.Verify(
                    p => p.AddStep(InitiatingMessagingStepMock.Object),
                    Times.Never());
                MessagingStepMock.Verify(
                    ms => ms.TrackActivity(It.IsAny <ActivityTrackingModes>(), It.IsAny <TrackingStream>()),
                    Times.Once());
                ProcessMock.Verify(
                    p => p.AddStep(MessagingStepMock.Object),
                    Times.Once());
            }
        }
コード例 #4
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());
        }
コード例 #5
0
        public void TrackActivityWhenBatchTrackingContextOnlyHasProcessActivityId()
        {
            var batchTrackingContext = new BatchTrackingContext {
                ProcessActivityId = ActivityId.NewActivityId()
            };

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

            sut.TrackActivity(batchTrackingContext);

            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);
        }
コード例 #6
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);
        }