Exemplo n.º 1
0
        public void Contains_Test_String_True()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c"
            };

            Assert.Equal(true, list.Contains("b"));
        }
Exemplo n.º 2
0
        public void Add_String()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c"
            };

            Assert.Equal(new[] { "a", "b", "c" }, list);
        }
Exemplo n.º 3
0
        public void Remove_Value_False()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c"
            };

            Assert.False(list.Remove("d"));
        }
Exemplo n.º 4
0
        public void Last_Test_Ints()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 3
            };

            Assert.Equal(3, list.Last.GetData());
        }
Exemplo n.º 5
0
        public void FindLast_Test_Null_Int()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 3
            };

            Assert.Null(list.FindLast(4));
        }
Exemplo n.º 6
0
        public void Last_Test_Strings()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c"
            };

            Assert.Equal("c", list.Last.GetData());
        }
Exemplo n.º 7
0
        public void Contains_Test_True_Int()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 3
            };

            Assert.Equal(true, list.Contains(3));
        }
Exemplo n.º 8
0
        public void FindLast_Test_True_Int()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 3, 4, 2, 5
            };

            Assert.Equal(5, list.FindLast(2).Next.GetData());
        }
Exemplo n.º 9
0
        public void CountTest()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c"
            };
            int count = 3;

            Assert.Equal(count, list.Count);
        }
Exemplo n.º 10
0
        public void Clear_Test_Int()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 3
            };

            list.Clear();
            Assert.Empty(list);
        }
Exemplo n.º 11
0
        public void Clear_Test()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c"
            };

            list.Clear();
            Assert.Empty(list);
        }
Exemplo n.º 12
0
        public void Find_Test_True_Int()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 3
            };

            Node <int> node = new Node <int>(2);

            Assert.Equal(node.GetData(), list.Find(2).GetData());
        }
Exemplo n.º 13
0
        public void AddFirst_Value_Test_True_Int()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 4
            };
            int trei = 3;

            list.AddFirst(trei);
            Assert.Equal(3, list.First.GetData());
        }
Exemplo n.º 14
0
        public void AddFirst_Test_String_True()
        {
            var list = new DoubleCircularLinkedList <string> {
                "b", "c", "d"
            };
            Node <string> a = new Node <string>("a");

            list.AddFirst(a);
            Assert.Equal("a", list.First.GetData());
        }
Exemplo n.º 15
0
        public void AddLast_Value_Test_True_Int()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 4
            };
            int cinci = 5;

            list.AddLast(cinci);
            Assert.Equal(5, list.Last.GetData());
        }
Exemplo n.º 16
0
        public void CopyTo_Test_Strings()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c", "d", "e"
            };

            string[] arr   = new string[10];
            string[] array = { null, null, "a", "b", "c", "d", "e", null, null, null };
            list.CopyTo(arr, 2);
            Assert.Equal(array, arr);
        }
Exemplo n.º 17
0
        public void AddBefore_Value_Test_True_Int()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 4
            };
            Node <int> doi  = list.First.Next;
            int        trei = 3;

            list.AddAfter(doi, trei);
            Assert.Equal(3, list.Last.Previous.GetData());
        }
Exemplo n.º 18
0
        public void AddBefore_Test_True_Int()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 4
            };
            Node <int> doi  = list.Last;
            Node <int> trei = new Node <int>(3);

            list.AddBefore(doi, trei);
            Assert.Equal(3, list.Last.Previous.GetData());
        }
Exemplo n.º 19
0
        public void RemoveLast_Test_String_True()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c", "d"
            };

            Assert.Equal(4, list.Count);
            list.RemoveLast();
            Assert.Equal("c", list.Last.GetData());
            Assert.Equal(3, list.Count);
        }
Exemplo n.º 20
0
        public void CopyTo_Test_Int()
        {
            var list = new DoubleCircularLinkedList <int> {
                1, 2, 3, 4, 5
            };

            int[]  arr   = new int[8];
            int [] array = { 0, 0, 0, 1, 2, 3, 4, 5 };
            list.CopyTo(arr, 3);
            Assert.Equal(array, arr);
        }
Exemplo n.º 21
0
        public void Remove_Test_String_True()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c"
            };

            Assert.Equal(3, list.Count);
            list.Remove(list.First.Next);
            Assert.Equal("c", list.First.Next.GetData());
            Assert.Equal(2, list.Count);
        }
Exemplo n.º 22
0
        public void AddLast_Test_String_True()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c"
            };
            Node <string> last = list.Last;
            Node <string> d    = new Node <string>("d");

            list.AddLast(last, d);
            Assert.Equal("d", list.Last.GetData());
        }
Exemplo n.º 23
0
        public void AddAfter_ArgumentException_NodeToInsertAfter_Null_Test__Int()
        {
            var list = new DoubleCircularLinkedList <int>();

            Node <int> nodeList = list.Last;
            Node <int> newNode  = new Node <int>(1);

            var exception = Assert.Throws <ArgumentException>(() => list.AddAfter(nodeList, newNode));

            Assert.Equal("Node to insert after is null", exception.Message);
        }
Exemplo n.º 24
0
        public void Remove_Value_True()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c", "d", "e"
            };
            var Expectedlist = new DoubleCircularLinkedList <string> {
                "a", "b", "c", "e"
            };

            ;
            Assert.True(list.Remove("d"));
        }
Exemplo n.º 25
0
        public void Remove_Node_ArgumentNullException()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "c", "d"
            };

            Node <string> nullNode = null;

            var exception = Assert.Throws <ArgumentNullException>(() => list.Remove(nullNode));

            Assert.Equal("Value cannot be null.\r\nParameter name: node", exception.Message);
        }
Exemplo n.º 26
0
        public void CopyTo_ArgumentException_Strings()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c", "d", "e"
            };

            string[] array = new string[7];

            var exception = Assert.Throws <ArgumentException>(() => list.CopyTo(array, 3));

            Assert.Equal("Array length too small", exception.Message);
        }
Exemplo n.º 27
0
        public void CopyTo_ArgumentNullException_Strings()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c", "d", "e"
            };

            string[] array = null;

            var exception = Assert.Throws <ArgumentNullException>(() => list.CopyTo(array, 2));

            Assert.Equal("Value cannot be null.\r\nParameter name: index", exception.Message);
        }
Exemplo n.º 28
0
        public void CopyTo_ArgumentOutOfRangeException_IndexBigger_Than_ArrayLength()
        {
            var list = new DoubleCircularLinkedList <string> {
                "a", "b", "c"
            };

            string[] array = new string[5];

            var exception = Assert.Throws <ArgumentOutOfRangeException>(() => list.CopyTo(array, 6));

            Assert.Equal("Specified argument was out of the range of valid values.\r\nParameter name: index", exception.Message);
        }
Exemplo n.º 29
0
        public void Remove_Node_InvalidOperationException()
        {
            var list1 = new DoubleCircularLinkedList <string> {
                "a", "b", "c"
            };
            var list2 = new DoubleCircularLinkedList <string> {
                "a", "b",
            };

            var exception = Assert.Throws <InvalidOperationException>(() => list1.Remove(list2.Last));

            Assert.Equal("Node to remove is not member of list", exception.Message);
        }
Exemplo n.º 30
0
        public void AddAfter_InvalidOperationException_NodeToInsert_Test__Int()
        {
            var list1 = new DoubleCircularLinkedList <int> {
                1, 2, 3, 5
            };
            var list2 = new DoubleCircularLinkedList <int> {
                1, 2, 3, 4
            };

            Node <int> nodeList1 = list1.Last.Previous;
            Node <int> nodeList2 = list2.Last;

            var exception = Assert.Throws <InvalidOperationException>(() => list1.AddAfter(nodeList1, nodeList2));

            Assert.Equal("Node to insert is member of another list", exception.Message);
        }