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")); }
public void TestPush5() { LastInFirstOut <int> lifo = new LastInFirstOut <int>(); lifo.Push(1); lifo.Push(3); lifo.Push(5); lifo.Push(7); lifo.Push(9); lifo.Push(11); lifo.Remove(3); lifo.Push(10); lifo.Remove(5); lifo.Push(6); lifo.Remove(9); ReadOnlyCollection <int> expected = new ReadOnlyCollection <int>(new int[] { 1, 7, 11, 6, 10 }); 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.AreNotEqual(expected[3], actual[3]); Assert.AreNotEqual(expected[4], actual[4]); Assert.AreEqual(expected[4], actual[3]); Assert.AreEqual(expected[3], actual[4]); }
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 TestPush1() { LastInFirstOut<int> lifo = new LastInFirstOut<int>(); Assert.AreEqual(0, lifo.Stack.Count); lifo.Push(1); lifo.Push(3); Assert.AreEqual(2, lifo.Stack.Count); lifo.Push(5); Assert.AreEqual(3, lifo.Stack.Count); lifo.Push(7); lifo.Push(9); lifo.Push(11); ReadOnlyCollection<int> expected = new ReadOnlyCollection<int>(new int[] { 1, 3, 5, 7, 9, 11 }); 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]); Assert.AreEqual(expected[4], actual[4]); Assert.AreEqual(expected[5], actual[5]); }
public void TestPush1() { LastInFirstOut <int> lifo = new LastInFirstOut <int>(); Assert.AreEqual(0, lifo.Stack.Count); lifo.Push(1); lifo.Push(3); Assert.AreEqual(2, lifo.Stack.Count); lifo.Push(5); Assert.AreEqual(3, lifo.Stack.Count); lifo.Push(7); lifo.Push(9); lifo.Push(11); ReadOnlyCollection <int> expected = new ReadOnlyCollection <int>(new int[] { 1, 3, 5, 7, 9, 11 }); 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]); Assert.AreEqual(expected[4], actual[4]); Assert.AreEqual(expected[5], actual[5]); }
public void TestPush3() { LastInFirstOut<int> lifo = new LastInFirstOut<int>(); lifo.Push(1); lifo.Push(3); lifo.Push(5); lifo.Push(7); lifo.Push(9); lifo.Push(11); lifo.Remove(3); lifo.Remove(5); lifo.Remove(9); ReadOnlyCollection<int> expected = new ReadOnlyCollection<int>(new int[] { 1, 7, 11 }); 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]); }
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]); }