Beispiel #1
0
        public void Includes_Returns_False()
        {
            //Arrange
            DataStructures.LinkedLists testList = new LinkedLists();
            testList.Insert(13);
            testList.Insert(12);

            //Act
            bool result = testList.Includes(11);

            //Assert
            Assert.False(result);
        }
Beispiel #2
0
        public void Head_Points_To_Next()
        {
            //Arrange
            DataStructures.LinkedLists testList = new LinkedLists();
            testList.Insert(13);
            string expected = "{12} => {13} => NULL";

            //Act
            testList.Insert(12);
            string result = testList.ToString();

            //Assert
            Assert.Equal(expected, result);
        }
Beispiel #3
0
        public void Append_To_End_Test()
        {
            //Arrange
            DataStructures.LinkedLists testList = new LinkedLists();
            testList.Insert(3);
            testList.Insert(1);
            string expected = "{1} => {3} => {13} => NULL";

            //Act
            testList.AppendToEnd(13);
            string actual = testList.ToString();

            //Assert
            Assert.Equal(expected, actual);
        }
Beispiel #4
0
        public void Knth_Is_Length_From_End_Test()
        {
            //Arrange
            DataStructures.LinkedLists testList = new LinkedLists();
            testList.Insert(44);
            testList.Insert(13);
            testList.Insert(86);
            testList.Insert(75);
            int userInput = 3;

            //act
            int actual = testList.KnthFromEnd(userInput);

            //assert
            Assert.Equal(75, actual);
        }
Beispiel #5
0
        public void Insert_After_Last_Node_Test()
        {
            //Arrange
            DataStructures.LinkedLists testList = new LinkedLists();
            testList.Insert(24);
            testList.Insert(13);
            testList.Insert(86);
            string expected = "{86} => {13} => {24} => {5} => NULL";

            //Act
            testList.InsertAfter(24, 5);
            string actual = testList.ToString();

            //Assert
            Assert.Equal(expected, actual);
        }
Beispiel #6
0
        public void Insert_Before_At_Start_Test()
        {
            //Arrange
            DataStructures.LinkedLists testList = new LinkedLists();
            testList.Insert(24);
            testList.Insert(13);
            testList.Insert(86);
            string expected = "{5} => {86} => {13} => {24} => NULL";

            //Act
            testList.InsertBefore(86, 5);
            string actual = testList.ToString();

            //Assert
            Assert.Equal(expected, actual);
        }
Beispiel #7
0
        public void Knth_Is_Where_K_Is_Negative_Test()
        {
            //Arrange
            DataStructures.LinkedLists testList = new LinkedLists();
            testList.Insert(44);
            testList.Insert(13);
            testList.Insert(86);
            testList.Insert(75);
            int userInput = -3;


            //Assert
            Assert.Throws <IndexOutOfRangeException>(() =>
            {
                //act
                int actual = testList.KnthFromEnd(userInput);
            });
        }
Beispiel #8
0
        public void Insert_After_No_Match_Test_Throws_Exception()
        {
            //Arrange
            DataStructures.LinkedLists testList = new LinkedLists();
            testList.Insert(24);
            testList.Insert(13);
            testList.Insert(86);
            //string expected = "{86} => {13} => {24} => NULL";



            //Assert
            Assert.Throws <ArgumentException>(() =>
            {
                //Act
                testList.InsertAfter(11, 5);
                string actual = testList.ToString();
            });
        }
Beispiel #9
0
        public void Can_Insert_Node()
        {
            //Arrange
            DataStructures.LinkedLists testList = new LinkedLists();

            //Act
            testList.Insert(13);

            //Assert
            Assert.Equal("{13} => NULL", testList.ToString());
        }
Beispiel #10
0
        public void Knth_For_List_Of_One()
        {
            //Arrange
            DataStructures.LinkedLists testList = new LinkedLists();
            testList.Insert(44);
            int userInput = 0;

            //act
            int actual = testList.KnthFromEnd(userInput);

            //assert
            Assert.Equal(44, actual);
        }