Pop() public method

Pops the current object off of the stack, returning its value.
public Pop ( ) : object
return object
示例#1
0
        public void IntegrityTest()
        {
            ContextStack stack = new ContextStack();

            string one = "one";
            string two = "two";
            stack.Push(two);
            stack.Push(one);
            Assert.Same(one, stack[typeof(string)]);
            Assert.Same(one, stack[0]);
            Assert.Same(one, stack.Current);

            Assert.Same(one, stack.Pop());

            Assert.Same(two, stack[typeof(string)]);
            Assert.Same(two, stack[0]);
            Assert.Same(two, stack.Current);

            string three = "three";
            stack.Append(three);

            Assert.Same(two, stack[typeof(string)]);
            Assert.Same(two, stack[0]);
            Assert.Same(two, stack.Current);

            Assert.Same(two, stack.Pop());

            Assert.Same(three, stack[typeof(string)]);
            Assert.Same(three, stack[0]);
            Assert.Same(three, stack.Current);
            Assert.Same(three, stack.Pop());

            Assert.Null(stack.Pop());
            Assert.Null(stack.Current);
        }
示例#2
0
		public void IntegrityTest ()
		{
			ContextStack stack = new ContextStack ();

			string one = "one";
			string two = "two";
			stack.Push (two);
			stack.Push (one);
			Assert.AreSame (one, stack [typeof (string)], "#1");
			Assert.AreSame (one, stack [0], "#2");
			Assert.AreSame (one, stack.Current, "#3");

			Assert.AreSame (one, stack.Pop (), "#4");

			Assert.AreSame (two, stack [typeof (string)], "#5");
			Assert.AreSame (two, stack [0], "#6");
			Assert.AreSame (two, stack.Current, "#7");

			string three = "three";
			stack.Append (three);

			Assert.AreSame (two, stack[typeof (string)], "#8");
			Assert.AreSame (two, stack[0], "#9");
			Assert.AreSame (two, stack.Current, "#10");

			Assert.AreSame (two, stack.Pop (), "#11");

			Assert.AreSame (three, stack[typeof (string)], "#12");
			Assert.AreSame (three, stack[0], "#13");
			Assert.AreSame (three, stack.Current, "#14");
			Assert.AreSame (three, stack.Pop (), "#15");

			Assert.IsNull (stack.Pop (), "#16");
			Assert.IsNull (stack.Current, "#17");
		}
示例#3
0
		[Test] // Item (Type)
		public void Indexer2 ()
		{
			ContextStack stack = new ContextStack ();

			Foo foo = new Foo ();
			FooBar foobar = new FooBar ();

			stack.Push (foobar);
			stack.Push (foo);
			Assert.AreSame (foo, stack [typeof (Foo)], "#1");
			Assert.AreSame (foo, stack [typeof (IFoo)], "#2");
			Assert.AreSame (foo, stack.Pop (), "#3");
			Assert.AreSame (foobar, stack [typeof (Foo)], "#4");
			Assert.AreSame (foobar, stack [typeof (FooBar)], "#5");
			Assert.AreSame (foobar, stack [typeof (IFoo)], "#6");
			Assert.IsNull (stack [typeof (string)], "#7");
		}
示例#4
0
		[Test] // Item (Int32)
		public void Indexer1 ()
		{
			ContextStack stack = new ContextStack ();
			string one = "one";
			string two = "two";

			stack.Push (one);
			stack.Push (two);

			Assert.AreSame (two, stack [0], "#1");
			Assert.AreSame (one, stack [1], "#2");
			Assert.IsNull (stack [2], "#3");
			Assert.AreSame (two, stack.Pop (), "#4");
			Assert.AreSame (one, stack [0], "#5");
			Assert.IsNull (stack [1], "#6");
			Assert.AreSame (one, stack.Pop (), "#7");
			Assert.IsNull (stack [0], "#8");
			Assert.IsNull (stack [1], "#9");
		}
示例#5
0
        [Fact] // Item (Int32)
        public void Indexer1()
        {
            ContextStack stack = new ContextStack();
            string one = "one";
            string two = "two";

            stack.Push(one);
            stack.Push(two);

            Assert.Same(two, stack[0]);
            Assert.Same(one, stack[1]);
            Assert.Null(stack[2]);
            Assert.Same(two, stack.Pop());
            Assert.Same(one, stack[0]);
            Assert.Null(stack[1]);
            Assert.Same(one, stack.Pop());
            Assert.Null(stack[0]);
            Assert.Null(stack[1]);
        }
示例#6
0
        [Fact] // Item (Type)
        public void Indexer2()
        {
            ContextStack stack = new ContextStack();

            Foo foo = new Foo();
            FooBar foobar = new FooBar();

            stack.Push(foobar);
            stack.Push(foo);
            Assert.Same(foo, stack[typeof(Foo)]);
            Assert.Same(foo, stack[typeof(IFoo)]);
            Assert.Same(foo, stack.Pop());
            Assert.Same(foobar, stack[typeof(Foo)]);
            Assert.Same(foobar, stack[typeof(FooBar)]);
            Assert.Same(foobar, stack[typeof(IFoo)]);
            Assert.Null(stack[typeof(string)]);
        }