Example #1
0
        public void FifthLastReturnsAKnownValue()
        {
            // this is just a final sanity test

            LinkedIntList list = new LinkedIntList();

            list.Add(134);
            list.Add(5823);
            list.Add(-12);
            list.Add(0);
            list.Add(132);
            list.Add(5209);

            Assert.Equal(5823, list.GetFifthLast());
            list.Add(1305);
            Assert.Equal(-12, list.GetFifthLast());
        }
Example #2
0
        public void FifthLastReturnsAppropriateValues()
        {
            LinkedIntList list = new LinkedIntList();

            int initialListCount = 5;

            // seed the list with values 1 - 5
            for (int i = 1; i <= initialListCount; i++)
            {
                Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
                list.Add(i);
            }

            // Check values as we add more
            for (int i = 1; i <= 5; i++)
            {
                Assert.Equal(i, list.GetFifthLast());
                list.Add(i + initialListCount);
            }
        }
Example #3
0
 public void FifthLastErrorsWithLessThanFiveElements()
 {
     LinkedIntList list = new LinkedIntList();
     Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
     list.Add(1);
     Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
     list.Add(2);
     Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
     list.Add(3);
     Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
     list.Add(4);
     Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
     list.Add(5);
     Assert.DoesNotThrow((() => { list.GetFifthLast(); }));
     list.Add(6);
     Assert.DoesNotThrow((() => { list.GetFifthLast(); }));
     list.Add(7);
 }
Example #4
0
        public void FifthLastErrorsWithLessThanFiveElements()
        {
            LinkedIntList list = new LinkedIntList();

            Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
            list.Add(1);
            Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
            list.Add(2);
            Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
            list.Add(3);
            Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
            list.Add(4);
            Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
            list.Add(5);
            Assert.DoesNotThrow((() => { list.GetFifthLast(); }));
            list.Add(6);
            Assert.DoesNotThrow((() => { list.GetFifthLast(); }));
            list.Add(7);
        }
Example #5
0
        public void FifthLastReturnsAppropriateValues()
        {
            LinkedIntList list = new LinkedIntList();

            int initialListCount = 5;
            // seed the list with values 1 - 5
            for (int i = 1; i <= initialListCount; i++) {
                Assert.Throws(typeof(IndexOutOfRangeException), (() => { list.GetFifthLast(); }));
                list.Add(i);
            }

            // Check values as we add more
            for (int i = 1; i <= 5; i++) {
                Assert.Equal(i, list.GetFifthLast());
                list.Add(i + initialListCount);
            }
        }
Example #6
0
        public void FifthLastReturnsAKnownValue()
        {
            // this is just a final sanity test

            LinkedIntList list = new LinkedIntList();
            list.Add(134);
            list.Add(5823);
            list.Add(-12);
            list.Add(0);
            list.Add(132);
            list.Add(5209);

            Assert.Equal(5823, list.GetFifthLast());
            list.Add(1305);
            Assert.Equal(-12, list.GetFifthLast());
        }