Exemplo n.º 1
0
        public void CustomNestedScopeContextBasicTest()
        {
            var csc = new CustomScopeContext(true, false, false);

            Assert.False(csc.InitCalled);
            Assert.False(csc.DisposeCalled);
            Assert.False(csc.CompleteNowCalled);
            Assert.False(csc.Completed);
            using (var scope = new Scope(csc))
            {
                CustomNestedScopeContextBasicLevel1(scope);
                Assert.Same(scope, Scope.Current);
                Assert.NotNull(Scope.Current.GetScopeContext <CustomScopeContext>());
                Assert.Same(csc, Scope.Current.GetScopeContext <CustomScopeContext>());

                Assert.True(csc.InitCalled);
                Assert.False(csc.DisposeCalled);
                Assert.False(csc.CompleteNowCalled);
                Assert.False(csc.Completed);
                scope.Complete();
                Assert.True(csc.InitCalled);
                Assert.False(csc.DisposeCalled);
                Assert.False(csc.CompleteNowCalled);
                Assert.False(csc.Completed);
            }
            Assert.True(csc.InitCalled);
            Assert.True(csc.DisposeCalled);
            Assert.True(csc.CompleteNowCalled);
            Assert.True(csc.Completed);
            Assert.Null(Scope.Current);
        }
Exemplo n.º 2
0
        //[Fact]
        //public void CustomNestedScopeContextNotCompleteTest()
        //{
        //    var csc = new CustomScopeContext(true, false, false);
        //    Assert.False(csc.InitCalled);
        //    Assert.False(csc.DisposeCalled);
        //    Assert.False(csc.CompleteNowCalled);
        //    Assert.False(csc.Completed);
        //    using (var scope = new Scope(csc))
        //    {
        //        Assert.True(csc.InitCalled);
        //        Assert.False(csc.DisposeCalled);
        //        Assert.False(csc.CompleteNowCalled);
        //        Assert.False(csc.Completed);
        //    }
        //    Assert.True(csc.InitCalled);
        //    Assert.True(csc.DisposeCalled);
        //    Assert.True(csc.CompleteNowCalled);
        //    Assert.False(csc.Completed);
        //}

        private static void CustomNestedScopeContextBasicLevel1(Scope expected)
        {
            var csc = new CustomScopeContext(true, false, false);

            Assert.False(csc.InitCalled);
            Assert.False(csc.DisposeCalled);
            Assert.False(csc.CompleteNowCalled);
            Assert.False(csc.Completed);
            using (var scope = new Scope(csc))
            {
                Assert.NotSame(scope, Scope.Current);
                Assert.Equal(scope, Scope.Current);
                Assert.Equal(Scope.Current, scope);
                Assert.NotNull(Scope.Current.GetScopeContext <CustomScopeContext>());
                csc = Scope.Current.GetScopeContext <CustomScopeContext>();

                Assert.True(csc.InitCalled);
                Assert.False(csc.DisposeCalled);
                Assert.False(csc.CompleteNowCalled);
                Assert.False(csc.Completed);
                NestedMethod(expected);
                scope.Complete();
                Assert.True(csc.InitCalled);
                Assert.False(csc.DisposeCalled);
                Assert.False(csc.CompleteNowCalled);
                Assert.False(csc.Completed);
            }
            Assert.True(csc.InitCalled);
            Assert.False(csc.DisposeCalled);
            Assert.False(csc.CompleteNowCalled);
            Assert.False(csc.Completed);
            Assert.NotNull(Scope.Current);
        }
Exemplo n.º 3
0
        public void CustomScopeContextBasicTest()
        {
            var csc = new CustomScopeContext(true, false, false);

            Assert.False(csc.InitCalled);
            Assert.False(csc.DisposeCalled);
            Assert.False(csc.CompleteNowCalled);
            Assert.False(csc.Completed);
            using (var scope = new Scope(csc))
            {
                Assert.True(csc.InitCalled);
                Assert.False(csc.DisposeCalled);
                Assert.False(csc.CompleteNowCalled);
                Assert.False(csc.Completed);
                scope.Complete();
                Assert.True(csc.InitCalled);
                Assert.False(csc.DisposeCalled);
                Assert.False(csc.CompleteNowCalled);
                Assert.False(csc.Completed);
            }
            Assert.True(csc.InitCalled);
            Assert.True(csc.DisposeCalled);
            Assert.True(csc.CompleteNowCalled);
            Assert.True(csc.Completed);
        }