コード例 #1
0
        public void Insert_new_node_in_list()
        {
            LinkedLister list = new LinkedLister();

            list.Insert(5);
            list.Insert(6);
            list.Insert(8);
            list.Insert(9);

            list.Append(3);

            Assert.Equal("Hello", list.ToString());
        }
コード例 #2
0
        public void Insert_new_node_in_list()
        {
            // Arrange
            LinkedLister list = new LinkedLister();

            list.Insert(5);
            list.Insert(6);

            // Act
            list.Append(3);

            // Assert
            Assert.Equal("{ 6 } -> { 5 } -> { 3 } -> NULL", list.ToString());
        }
コード例 #3
0
        public void Includes_finds_input_in_list()
        {
            //Arrange
            LinkedLister list = new LinkedLister();

            //Act
            list.Insert(1);
            list.Insert(2);
            list.Insert(3);
            list.Insert(4);
            list.Insert(5);

            //Assert
            bool expected = false;

            Assert.Equal(list.Includes(4), expected);
        }
コード例 #4
0
        public void Insert_adds_value_to_start()
        {
            //Arrange
            LinkedLister list = new LinkedLister();

            //Act
            list.Insert(1);

            //Assert
            Assert.Equal("{ 1 } -> NULL", list.ToString());

            //Act
            list.Insert(2);

            //Assert
            Assert.Equal("{ 2 } -> { 1 } -> NULL", list.ToString());
        }
コード例 #5
0
        public void Includes_finds_input_in_list(int valueToFind, bool expected)
        {
            //Arrange
            LinkedLister list = new LinkedLister();

            list.Insert(1);
            list.Insert(2);
            list.Insert(3);
            list.Insert(4);
            list.Insert(5);

            //Act
            bool result = list.Includes(valueToFind);

            //Assert
            Assert.Equal(expected, result);
        }
コード例 #6
0
        public void InsertBefore_throws_for_missing_value_in_non_empty_list()
        {
            // Arrange
            LinkedLister list = new LinkedLister();

            list.Insert(1);

            // Assert
            Exception ex = Assert.Throws <ValueMissingException>(() =>
            {
                // Act
                list.InsertBefore(5, 1);
            });

            Assert.Equal("Value 5 is missing.", ex.Message);
        }