Example #1
0
        public void UndoTest()
        {
            var args    = new[] { "the", "fat", "cat", "sat", "on", "the", "mat" };
            var popList = new PopQueue <string>(args);

            Assert.AreEqual(args.Length, popList.Count);
            var pop1 = popList.PopFront();
            var pop2 = popList.PopFront();

            Assert.AreEqual(("the", 0), pop1);
            Assert.AreEqual(("fat", 1), pop2);
            popList.Undo();
            var pop3 = popList.PopFront();

            Assert.AreEqual(("fat", 1), pop3);
            var pop4 = new PopQueue <string>(args.Take(2).ToArray());

            pop4.PopFront();
            pop4.PopFront();
            pop4.Undo();
            pop4.Undo();
            Assert.ThrowsException <InvalidOperationException>(() => pop4.Undo());
            var pop5 = new PopQueue <string>(new string[] { });

            Assert.ThrowsException <InvalidOperationException>(() => pop5.Undo());
        }
Example #2
0
        public void PopListTest()
        {
            var args    = new[] { "the", "fat", "cat", "sat", "on", "the", "mat" };
            var popList = new PopQueue <string>(args);

            Assert.AreEqual(args.Length, popList.Count);
            var popList2 = new PopQueue <string>(args, 2);

            Assert.AreEqual(args.Length - 2, popList2.Count);
        }