Exemplo n.º 1
0
        public void Should_Delete_Element_From_Single_Element_List_With_Index()
        {
            LinkedListHelpers <char> .Clear();

            LinkedListHelpers <char> .Append('A');

            LinkedListHelpers <char> .RemoveAt(0);

            Assert.Equal(0, LinkedListHelpers <char> .Count);
            Assert.Equal(new char[] { }, LinkedListHelpers <char> .ToArray());//empty
        }
Exemplo n.º 2
0
        public void Should_Append_To_NonEmpty_List()
        {
            LinkedListHelpers <char> .Clear();

            LinkedListHelpers <char> .Append('A');

            LinkedListHelpers <char> .Append('B');

            Assert.Equal(2, LinkedListHelpers <char> .Count);

            Assert.NotEqual(new char[] { 'A', 'B' }, LinkedListHelpers <char> .ToArray());
            Assert.Equal(new char[] { 'B', 'A' }, LinkedListHelpers <char> .ToArray());
        }
Exemplo n.º 3
0
        public void Should_Append_To_Empty_List()
        {
            LinkedListHelpers <char> .Clear();

            LinkedListHelpers <char> .Append('A');

            Assert.Equal('A', LinkedListHelpers <char> ._getElementAt(0));
            Assert.Equal(1, LinkedListHelpers <char> .Count);

            LinkedListHelpers <char> .RemoveAt(0);

            Assert.Equal(0, LinkedListHelpers <char> .Count);
        }
Exemplo n.º 4
0
        public void Should_Not_Throw_When_Deleting_From_Empty_List_After_Appending_Some_Data()
        {
            LinkedListHelpers <char> .Clear();

            LinkedListHelpers <char> .Append('A');

            LinkedListHelpers <char> .Remove('A');

            LinkedListHelpers <char> .Remove('A');

            Assert.Equal(0, LinkedListHelpers <char> .Count);

            Assert.Equal(new char[] { }, LinkedListHelpers <char> .ToArray());
        }
Exemplo n.º 5
0
        public void Should_Delete_Element_At_The_End_Typeof_Int()
        {
            LinkedListHelpers <char> .Clear();

            LinkedListHelpers <char> .Append('A'); //head.next.next

            LinkedListHelpers <char> .Append('B'); //head.next

            LinkedListHelpers <char> .Append('C'); //head

            LinkedListHelpers <char> .RemoveAt(2);

            Assert.Equal(2, LinkedListHelpers <char> .Count);
            Assert.Equal(new char[] { 'C', 'B' }, LinkedListHelpers <char> .ToArray());
        }
Exemplo n.º 6
0
        public void Should_Do_Nothing_No_Duplicates_Greater_Than_3()
        {
            LinkedListHelpers <char> .Clear();

            LinkedListHelpers <char> .Append('A');

            LinkedListHelpers <char> .Append('B');

            LinkedListHelpers <char> .Append('E');

            LinkedListHelpers <char> .Append('B');

            LinkedListHelpers <char> .Append('E');

            LinkedListHelpers <char> .removeDuplicates();//removes duplicates leaving two if any

            Assert.Equal(5, LinkedListHelpers <char> .Count);
            Assert.Equal(new char[] { 'E', 'B', 'E', 'B', 'A' }, LinkedListHelpers <char> .ToArray());
        }
Exemplo n.º 7
0
        public void Should_Not_Add_Elements_of_Type_Int_or_Any__To_Char()
        {
            LinkedListHelpers <char> .Clear();

            LinkedListHelpers <char> .Append('A');

            LinkedListHelpers <char> .Append('B');

            LinkedListHelpers <char> .Append('E');

            LinkedListHelpers <char> .Append('B');

            LinkedListHelpers <char> .Append('E');

            LinkedListHelpers <int> .Append(1);           //this is not added

            LinkedListHelpers <char> .removeDuplicates(); //removes duplicates leaving two if any

            Assert.Equal(5, LinkedListHelpers <char> .Count);
            Assert.Equal(new char[] { 'E', 'B', 'E', 'B', 'A' }, LinkedListHelpers <char> .ToArray());
        }