Exemplo n.º 1
0
        public void CaptureOfOutboundMessageDoesNotPiggyBackKernelTransaction()
        {
            MessageMock.Setup(m => m.GetProperty(BtsProperties.OutboundTransportLocation)).Returns("outbound-transport-location");

            using (new TransactionScope())
                using (var stream = new MemoryStream())
                {
                    MessageMock.Object.BodyPart.Data = stream;

                    var transaction = TransactionInterop.GetDtcTransaction(Transaction.Current);
                    PipelineContextMock.As <IPipelineContextEx>()
                    .Setup(pc => pc.GetTransaction())
                    .Returns((IKernelTransaction)transaction);

                    var sut = MessageBodyTracker.Create(new MicroComponent.ActivityTracker.Context(PipelineContextMock.Object, MessageMock.Object, ActivityTrackingModes.Body));
                    sut.SetupTracking();

                    ClaimStoreMock.Verify(
                        cs => cs.SetupMessageBodyCapture(
                            It.IsAny <TrackingStream>(),
                            It.IsAny <ActivityTrackingModes>(),
                            It.Is <Func <IKernelTransaction> >(ktf => ktf == null)),
                        Times.Once());
                }
        }
Exemplo n.º 2
0
        public void InboundMessageBodyIsNotCheckedIn()
        {
            var sut = MessageBodyTracker.Create(new MicroComponent.ActivityTracker.Context(PipelineContextMock.Object, MessageMock.Object, ActivityTrackingModes.Body));

            sut.TryCheckInMessageBody();

            ClaimStoreMock.Verify(cs => cs.Claim(MessageMock.Object, It.IsAny <IResourceTracker>()), Times.Never());
        }
Exemplo n.º 3
0
        public void OutboundMessageBodyIsNotCheckedOut()
        {
            MessageMock.Setup(m => m.GetProperty(BtsProperties.OutboundTransportLocation)).Returns("outbound-transport-location");

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

            sut.TryCheckOutMessageBody();

            ClaimStoreMock.Verify(cs => cs.Redeem(MessageMock.Object, It.IsAny <IResourceTracker>()), Times.Never());
        }
Exemplo n.º 4
0
        public void CaptureIsNotSetupIfTrackingStreamAlreadyHasCaptureDescriptor()
        {
            using (var trackingStream = new TrackingStream(new MemoryStream(), new MessageBodyCaptureDescriptor("url", MessageBodyCaptureMode.Claimed)))
            {
                MessageMock.Object.BodyPart.Data = trackingStream;

                var sut = MessageBodyTracker.Create(new MicroComponent.ActivityTracker.Context(PipelineContextMock.Object, MessageMock.Object, ActivityTrackingModes.Body));
                sut.SetupTracking();
            }

            ClaimStoreMock.Verify(
                cs => cs.SetupMessageBodyCapture(It.IsAny <TrackingStream>(), It.IsAny <ActivityTrackingModes>(), It.IsAny <Func <IKernelTransaction> >()),
                Times.Never());
        }
Exemplo n.º 5
0
        public void CaptureOfInboundMessageIsSetup()
        {
            using (var stream = new MemoryStream())
            {
                MessageMock.Object.BodyPart.Data = stream;

                var sut = MessageBodyTracker.Create(new MicroComponent.ActivityTracker.Context(PipelineContextMock.Object, MessageMock.Object, ActivityTrackingModes.Body));
                sut.SetupTracking();
            }

            ClaimStoreMock.Verify(
                cs => cs.SetupMessageBodyCapture(It.IsAny <TrackingStream>(), It.IsAny <ActivityTrackingModes>(), It.Is <Func <IKernelTransaction> >(ktf => ktf != null)),
                Times.Once());

            MessageMock.Object.BodyPart.Data.Should().BeOfType <TrackingStream>();
        }
Exemplo n.º 6
0
        public void CaptureOfOutboundMessageIsSetup()
        {
            MessageMock.Setup(m => m.GetProperty(BtsProperties.OutboundTransportLocation)).Returns("outbound-transport-location");

            using (var stream = new MemoryStream())
            {
                MessageMock.Object.BodyPart.Data = stream;

                var sut = MessageBodyTracker.Create(new MicroComponent.ActivityTracker.Context(PipelineContextMock.Object, MessageMock.Object, ActivityTrackingModes.Body));
                sut.SetupTracking();
            }

            ClaimStoreMock.Verify(
                cs => cs.SetupMessageBodyCapture(It.IsAny <TrackingStream>(), It.IsAny <ActivityTrackingModes>(), It.Is <Func <IKernelTransaction> >(ktf => ktf == null)),
                Times.Once());

            MessageMock.Object.BodyPart.Data.Should().BeOfType <TrackingStream>();
        }
Exemplo n.º 7
0
        public void CaptureOfInboundMessagePiggiesBackKernelTransaction()
        {
            using (new TransactionScope())
                using (var stream = new MemoryStream())
                {
                    MessageMock.Object.BodyPart.Data = stream;

                    var transaction = (IKernelTransaction)TransactionInterop.GetDtcTransaction(Transaction.Current);
                    PipelineContextMock.As <IPipelineContextEx>()
                    .Setup(pc => pc.GetTransaction())
                    .Returns(transaction);

                    var sut = MessageBodyTracker.Create(new MicroComponent.ActivityTracker.Context(PipelineContextMock.Object, MessageMock.Object, ActivityTrackingModes.Body));
                    sut.SetupTracking();

                    // TODO upgrade Moq
                    ClaimStoreMock.Verify(
                        cs => cs.SetupMessageBodyCapture(
                            It.IsAny <TrackingStream>(),
                            It.IsAny <ActivityTrackingModes>(),
                            It.Is <Func <IKernelTransaction> >(ktf => ReferenceEquals(ktf(), transaction))),
                        Times.Once());
                }
        }