Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public void IsReadOnlyAddFirstMethodException()
        {
            var test = new LinkedListCollection <int>();

            test.Add(1);
            test.Add(2);
            test = test.ReadOnlyList();
            Assert.Throws <NotSupportedException>(() => test.AddFirst(3));
        }
Ejemplo n.º 4
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));
        }
        public void ValidatesAddLastMethodForEmptyList()
        {
            var list = new LinkedListCollection <int>();

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

            list.Add(4);
            Assert.Equal(4, list.GetLast.Value);
        }
Ejemplo n.º 7
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));
        }