public void ValidatesAddFirstMethodForEmptyList()
        {
            var list = new LinkedListCollection <int>();

            list.AddFirst(4);
            Assert.Equal(4, list.GetFirst.Value);
        }
        public void ValidatesCointainsMethod()
        {
            var list = new LinkedListCollection <int> {
                1, 2, 3
            };

            Assert.Contains(2, list);
        }
        public void ValidatesFindLastMethod()
        {
            var list = new LinkedListCollection <int> {
                1, 2, 3, 4, 5
            };

            Assert.Equal(list.GetLast.Previous, list.Find(4));
        }
        public void ValidatesRemoveMethodThatReturnsFalse()
        {
            var list = new LinkedListCollection <int> {
                1, 2, 3
            };

            Assert.False(list.Remove(4));
        }
        public void ValidatesFindFirstMethod()
        {
            var list = new LinkedListCollection <int> {
                1, 2, 3
            };

            Assert.Equal(list.GetFirst, list.Find(1));
        }
        public void ValidatesClearMethod()
        {
            var list = new LinkedListCollection <int> {
                1, 2, 3
            };

            list.Clear();
            Assert.Empty(list);
        }
Пример #7
0
        public void NegativeIndexCopyToMethodException()
        {
            var test = new LinkedListCollection <int>();

            int[] testArray = new int[4];
            test.Add(1);
            test.Add(2);
            Assert.Throws <ArgumentOutOfRangeException>(() => test.CopyTo(testArray, -1));
        }
Пример #8
0
        public void ArrayNullCopyToMethodException()
        {
            var test = new LinkedListCollection <int>();

            int[] testArray = null;
            test.Add(1);
            test.Add(2);
            Assert.Throws <ArgumentNullException>(() => test.CopyTo(testArray, 0));
        }
Пример #9
0
        public void NullNodeAddFirstMethodException()
        {
            var test = new LinkedListCollection <int> {
                1, 2
            };
            LinkedListNode <int> testNode = null;

            Assert.Throws <ArgumentNullException>(() => test.AddFirst(testNode));
        }
Пример #10
0
        public void IsReadOnlyAddFirstMethodException()
        {
            var test = new LinkedListCollection <int>();

            test.Add(1);
            test.Add(2);
            test = test.ReadOnlyList();
            Assert.Throws <NotSupportedException>(() => test.AddFirst(3));
        }
Пример #11
0
        public void ArgumentNullRemoveMethodException()
        {
            var test = new LinkedListCollection <int> {
                1, 2
            };
            LinkedListNode <int> nullNode = null;

            Assert.Throws <ArgumentNullException>(() => test.Remove(nullNode));
        }
Пример #12
0
        public void NullItemAddMethodException()
        {
            var test = new LinkedListCollection <int?> {
                1, 2
            };
            int?testNode = null;

            Assert.Throws <ArgumentNullException>(() => test.AddLast(testNode));
        }
        public void ValidatesAddFirstMethodForListWithElements()
        {
            var list = new LinkedListCollection <int> {
                1, 2, 3
            };

            list.AddFirst(4);
            Assert.Equal(4, list.GetFirst.Value);
        }
        public void ValidatesRemoveFirstMethod()
        {
            var list = new LinkedListCollection <int> {
                1, 2, 3
            };

            list.RemoveFirst();
            Assert.Equal(2, list.GetFirst.Value);
        }
        public void ValidatesAddAfterMethod()
        {
            var list = new LinkedListCollection <int> {
                1, 3, 4
            };

            list.AddAfter(list.GetFirst, 2);
            Assert.Equal(2, list.GetFirst.Next.Value);
        }
        public void ValidatesAddBeforeMethod()
        {
            var list = new LinkedListCollection <int> {
                1, 2, 4
            };

            list.AddBefore(list.GetLast, 3);
            Assert.Equal(3, list.GetLast.Previous.Value);
        }
        public void ValidatesRemoveMethod()
        {
            var list = new LinkedListCollection <int> {
                1, 2, 3
            };

            Assert.True(list.Remove(2));
            Assert.Equal(1, list.GetFirst.Value);
            Assert.Equal(3, list.GetLast.Value);
        }
Пример #18
0
        public void AddMethodInvalidOperationException()
        {
            var test = new LinkedListCollection <int> {
                1, 2
            };
            LinkedListNode <int> node = new LinkedListNode <int>(2);

            test.Add(node);
            Assert.Throws <InvalidOperationException>(() => test.Add(node));
        }
Пример #19
0
        public void RemoveMethodInvalidOperationException()
        {
            var test = new LinkedListCollection <int> {
                1, 2
            };
            var secondTestList = new LinkedListCollection <int> {
                1, 2
            };
            LinkedListNode <int> node = new LinkedListNode <int>(3);

            secondTestList.Add(node);
            Assert.Throws <InvalidOperationException>(() => test.Remove(node));
        }
        public void ValidateConstructorWithGivenArray()
        {
            int[] array = new[] { 1, 2, 3, 4 };
            var   list  = new LinkedListCollection <int>(array);

            Assert.Equal(1, list.GetFirst.Value);
            Assert.Equal(4, list.GetLast.Value);
            LinkedListNode <int> current = list.GetFirst;

            foreach (int digit in array)
            {
                Assert.Equal(digit, current.Value);
                current = current.Next;
            }
        }
        public void ValidatesCopyToMethod()
        {
            var list = new LinkedListCollection <int> {
                1, 2, 3
            };
            var array = new int[3];

            list.CopyTo(array, 0);
            LinkedListNode <int> node = list.GetFirst;

            foreach (var x in array)
            {
                Assert.Equal(x, node.Value);
                node = node.Next;
            }
        }
        public void ValidateImplicitConstructor()
        {
            var list = new LinkedListCollection <int>();

            Assert.Empty(list);
        }