コード例 #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));
        }
コード例 #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>());
        }
コード例 #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));
        }
コード例 #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>());
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #15
0
        public void TestGet_Throw_Exception_On_Empty_List()
        {
            LinkedList <Employee> linkedList = new LinkedList <Employee>();

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