Exemplo n.º 1
0
        public void TestAddHead()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp = new Employee(1);

            linkedList.Add(emp);
            Assert.That(linkedList.Get(), Is.EqualTo(emp));
        }
Exemplo n.º 2
0
        public void TestGetPosition_Throws_Exception_On_Invalid_Position()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);

            linkedList.Add(emp1);
            Assert.That(() => linkedList.Get(2), Throws.Exception.TypeOf <IndexOutOfRangeException>());
        }
Exemplo n.º 3
0
        public void TestAddLast_Size_0()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);

            linkedList.AddLast(emp1);

            Assert.That(linkedList.Get(), Is.EqualTo(emp1));
        }
Exemplo n.º 4
0
        public void TestGetData_Throws_Exception_When_Node_Is_Null()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);
            Employee emp2 = new Employee(2);

            linkedList.InsertData(emp1);

            Assert.That(() => linkedList.Get(emp2), Throws.Exception.TypeOf <IndexOutOfRangeException>());
        }
Exemplo n.º 5
0
        public void TestGetSuccess()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp = new Employee(1);

            linkedList.Add(emp);

            Employee employeeData = linkedList.Get();

            Assert.That(emp, Is.EqualTo(employeeData));
        }
Exemplo n.º 6
0
        public void TestGetData_Returns_Proper_Data()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);
            Employee emp2 = new Employee(2);

            linkedList.InsertData(emp1);
            linkedList.InsertData(emp2);

            Assert.That(linkedList.Get(emp1), Is.EqualTo(emp1));
        }
Exemplo n.º 7
0
        public void TestGetPosition_Returns_Correct_Data()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);
            Employee emp2 = new Employee(2);

            linkedList.Add(emp1);
            linkedList.Add(emp2);

            Assert.That(linkedList.Get(2), Is.EqualTo(emp1));
        }
Exemplo n.º 8
0
        public void TestAddFirst()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);
            Employee emp2 = new Employee(2);

            linkedList.Add(emp1);
            linkedList.AddFirst(emp2);

            Assert.That(linkedList.Get(), Is.EqualTo(emp2));
        }
Exemplo n.º 9
0
        public void TestAddBefore_Position_In_Middle_Of_List()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);
            Employee emp2 = new Employee(2);
            Employee emp3 = new Employee(3);

            linkedList.Add(emp3);
            linkedList.Add(emp1);

            linkedList.AddBefore(emp2, 2);
            Assert.That(linkedList.Get(2), Is.EqualTo(emp2));
        }
Exemplo n.º 10
0
        public void TestInsertData_Current_Data_Inserted_Middle_Of_List()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);
            Employee emp2 = new Employee(2);
            Employee emp3 = new Employee(3);

            linkedList.Add(emp3);
            linkedList.Add(emp1);

            linkedList.InsertData(emp2);
            Assert.That(linkedList.Get(2), Is.EqualTo(emp2));
        }
Exemplo n.º 11
0
        public void TestSetSuccess()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);
            Employee emp2 = new Employee(2);

            linkedList.Add(emp1);

            Employee oldData = linkedList.Set(emp2);

            Assert.That(emp2, Is.EqualTo(linkedList.Get()));
            Assert.That(emp1, Is.EqualTo(oldData));
        }
Exemplo n.º 12
0
        public void TestSet_Data_OldData_Replaces_Node()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);
            Employee emp2 = new Employee(2);
            Employee emp3 = new Employee(3);
            Employee emp4 = new Employee(4);

            linkedList.InsertData(emp1);
            linkedList.InsertData(emp3);
            linkedList.InsertData(emp4);

            linkedList.Set(emp2, emp3);
            Assert.That(linkedList.Get(2), Is.EqualTo(emp2));
        }
Exemplo n.º 13
0
        public void TestAddBefore_Node_Is_In_The_Middle_Of_The_List()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);
            Employee emp2 = new Employee(2);
            Employee emp3 = new Employee(3);
            Employee emp4 = new Employee(4);

            linkedList.InsertData(emp1);
            linkedList.InsertData(emp2);
            linkedList.InsertData(emp4);

            linkedList.AddBefore(emp3, emp4);
            Assert.That(linkedList.Get(3), Is.EqualTo(emp3));
        }
Exemplo n.º 14
0
        public void TestSet_Position_In_Middle_Of_List()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();
            Employee emp1 = new Employee(1);
            Employee emp2 = new Employee(2);
            Employee emp3 = new Employee(3);
            Employee emp4 = new Employee(4);

            linkedList.InsertData(emp1);
            linkedList.InsertData(emp2);
            linkedList.InsertData(emp3);

            linkedList.Set(emp4, 2);
            Assert.That(linkedList.Get(2), Is.EqualTo(emp4));
        }
Exemplo n.º 15
0
        public void TestGet_Throw_Exception_On_Empty_List()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();

            Assert.That(() => linkedList.Get(), Throws.Exception.TypeOf <IndexOutOfRangeException>());
        }