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());
                }
        }
        public void CaptureOfInboundMessagePiggiesBackKernelTransaction()
        {
            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())
                    // ReSharper disable once SuspiciousTypeConversion.Global
                    .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>(),
                            // ReSharper disable once SuspiciousTypeConversion.Global
                            It.Is <Func <IKernelTransaction> >(ktf => ReferenceEquals(ktf(), transaction))),
                        Times.Once());
                }
        }