コード例 #1
0
        public void Pop_Ok()
        {
            var obj  = new BootstrapContext(viewContext, null, null, null);
            var obj1 = new Class1();
            var obj2 = new Class2();
            var obj3 = new Class1();

            obj.Push(obj1);
            obj.Push(obj2);
            obj.Push(obj3);

            // this throws error
            try
            {
                obj.PopIfEqual(obj2);
                Assert.True(false, "Should not got there :(");
            } catch (ArgumentException)
            {
                // It,s Ok
            }

            // obj3 is still at last positon
            obj.PopIfEqual(obj3);


            // and now can POP obj2
            obj.PopIfEqual(obj2);

            // and obj1 is last one
            obj.PopIfEqual(obj1);

            // nothing more
            Assert.Null(obj.PeekNearest <object>());
        }
コード例 #2
0
        public void Pop_Ok()
        {
            var obj = new BootstrapContext(viewContext, null, null, null);
            var obj1 = new Class1();
            var obj2 = new Class2();
            var obj3 = new Class1();

            obj.Push(obj1);
            obj.Push(obj2);
            obj.Push(obj3);

            // this throws error
            try
            {
                obj.PopIfEqual(obj2);
                Assert.True(false, "Should not got there :(");
            } catch (ArgumentException)
            {
                // It,s Ok
            }

            // obj3 is still at last positon
            obj.PopIfEqual(obj3);

            // and now can POP obj2
            obj.PopIfEqual(obj2);

            // and obj1 is last one
            obj.PopIfEqual(obj1);

            // nothing more
            Assert.Null(obj.PeekNearest<object>());
        }
コード例 #3
0
        public void PeekNearest_Ok()
        {
            var obj  = new BootstrapContext(viewContext, null, null, null);
            var obj1 = new Class1();
            var obj2 = new Class2();
            var obj3 = new Class1();

            obj.Push(obj1);
            obj.Push(obj2);
            obj.Push(obj3);

            Assert.Same(obj2, obj.PeekNearest <Class2>());
        }
コード例 #4
0
        public void PeekNearest_Ok()
        {
            var obj = new BootstrapContext(viewContext, null, null, null);
            var obj1 = new Class1();
            var obj2 = new Class2();
            var obj3 = new Class1();

            obj.Push(obj1);
            obj.Push(obj2);
            obj.Push(obj3);

            Assert.Same(obj2, obj.PeekNearest<Class2>());
        }