Example #1
0
        public void TestDeactivateWhenDifferentSpanIsActive()
        {
            ISpan span = Substitute.For <ISpan>();

            using (_scopeManager.Activate(span, finishSpanOnDispose: false))
            {
                _scopeManager.Activate(Substitute.For <ISpan>(), finishSpanOnDispose: false);
            }

            span.DidNotReceive().Finish();
        }
        public void DontFinishSpanNoDispose()
        {
            ISpan span = Substitute.For <ISpan>();

            using (IScope scope = _source.Activate(span, finishSpanOnDispose: false))
            {
                Assert.NotNull(scope);
                Assert.NotNull(_source.Active);
            }

            // Make sure the ISpan did *not* get finish()ed.
            span.DidNotReceive().Finish();

            // Verify it's gone.
            Assert.Null(_source.Active);
        }
        public void DefaultActivate()
        {
            ISpan span = Substitute.For <ISpan>();

            using (IScope scope = _source.Activate(span, finishSpanOnDispose: false))
            {
                Assert.NotNull(scope);
                IScope otherScope = _source.Active;
                Assert.Same(otherScope, scope);
            }

            // Make sure the span is not finished.
            span.DidNotReceive().Finish();

            // And now it's gone:
            IScope missingScope = _source.Active;

            Assert.Null(missingScope);
        }