Exemple #1
0
        public void LastInFirstOutTest()
        {
            var lastInFirstOut = new LastInFirstOut <string>(new BridgeListImpl <int, string>());

            lastInFirstOut.Push("string 1");
            lastInFirstOut.Push("string 2");
            lastInFirstOut.Push("string 3");

            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 3"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 2"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 1"));

            lastInFirstOut = new LastInFirstOut <string>(new BridgeDictionaryImpl <int, string>());

            lastInFirstOut.Push("string 1");
            lastInFirstOut.Push("string 2");
            lastInFirstOut.Push("string 3");

            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 3"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 2"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 1"));

            lastInFirstOut = new LastInFirstOut <string>(new BridgeNodeImpl <int, string>());

            lastInFirstOut.Push("string 1");
            lastInFirstOut.Push("string 2");
            lastInFirstOut.Push("string 3");

            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 3"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 2"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 1"));
        }
        public void LastInFirstOutTest()
        {
            var lastInFirstOut = new LastInFirstOut<string>(new BridgeListImpl<int, string>());

            lastInFirstOut.Push("string 1");
            lastInFirstOut.Push("string 2");
            lastInFirstOut.Push("string 3");

            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 3"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 2"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 1"));

            lastInFirstOut = new LastInFirstOut<string>(new BridgeDictionaryImpl<int, string>());

            lastInFirstOut.Push("string 1");
            lastInFirstOut.Push("string 2");
            lastInFirstOut.Push("string 3");

            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 3"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 2"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 1"));

            lastInFirstOut = new LastInFirstOut<string>(new BridgeNodeImpl<int, string>());

            lastInFirstOut.Push("string 1");
            lastInFirstOut.Push("string 2");
            lastInFirstOut.Push("string 3");

            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 3"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 2"));
            Assert.That(lastInFirstOut.Pop(), Is.EqualTo("string 1"));
        }
Exemple #3
0
        public void TestPop1()
        {
            ReadOnlyCollection <int> expected = new ReadOnlyCollection <int>(new int[] { 1, 3, 5, 7, 9, 11 });
            LastInFirstOut <int>     lifo     = new LastInFirstOut <int>(expected);

            Assert.AreEqual(expected[5], lifo.Pop());
            Assert.AreEqual(expected.Count - 1, lifo.Stack.Count);

            Assert.AreEqual(expected[4], lifo.Pop());
            Assert.AreEqual(expected[3], lifo.Pop());

            Assert.AreEqual(expected[2], lifo.Peek());
            Assert.AreEqual(expected[2], lifo.Pop());
            Assert.AreEqual(expected[1], lifo.Peek());
        }
Exemple #4
0
        public void TestPop2()
        {
            ReadOnlyCollection <int> expected = new ReadOnlyCollection <int>(new int[] { 1, 3, 5, 7, 9, 11 });
            LastInFirstOut <int>     lifo     = new LastInFirstOut <int>(expected);

            Assert.AreEqual(expected[5], lifo.Pop());
            Assert.AreEqual(expected[4], lifo.Pop());
            lifo.Push(10);
            Assert.AreEqual(10, lifo.Pop());
            lifo.Push(6);
            Assert.AreEqual(6, lifo.Pop());

            expected = new ReadOnlyCollection <int>(new int[] { 1, 3, 5, 7 });
            ReadOnlyCollection <int> actual = lifo.Stack;

            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected[0], actual[0]);
            Assert.AreEqual(expected[1], actual[1]);
            Assert.AreEqual(expected[2], actual[2]);
            Assert.AreEqual(expected[3], actual[3]);
        }
        public void TestPop2()
        {
            ReadOnlyCollection<int> expected = new ReadOnlyCollection<int>(new int[] { 1, 3, 5, 7, 9, 11 });
            LastInFirstOut<int> lifo = new LastInFirstOut<int>(expected);

            Assert.AreEqual(expected[5], lifo.Pop());
            Assert.AreEqual(expected[4], lifo.Pop());
            lifo.Push(10);
            Assert.AreEqual(10, lifo.Pop());
            lifo.Push(6);
            Assert.AreEqual(6, lifo.Pop());

            expected = new ReadOnlyCollection<int>(new int[] { 1, 3, 5, 7 });
            ReadOnlyCollection<int> actual = lifo.Stack;
            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected[0], actual[0]);
            Assert.AreEqual(expected[1], actual[1]);
            Assert.AreEqual(expected[2], actual[2]);
            Assert.AreEqual(expected[3], actual[3]);
        }
        public void TestPop1()
        {
            ReadOnlyCollection<int> expected = new ReadOnlyCollection<int>(new int[] { 1, 3, 5, 7, 9, 11 });
            LastInFirstOut<int> lifo = new LastInFirstOut<int>(expected);

            Assert.AreEqual(expected[5], lifo.Pop());
            Assert.AreEqual(expected.Count - 1, lifo.Stack.Count);

            Assert.AreEqual(expected[4], lifo.Pop());
            Assert.AreEqual(expected[3], lifo.Pop());

            Assert.AreEqual(expected[2], lifo.Peek());
            Assert.AreEqual(expected[2], lifo.Pop());
            Assert.AreEqual(expected[1], lifo.Peek());
        }