コード例 #1
0
            public void RemoveLastMethod_RemovesTheOnlyItemInTheList()
            {
                SimpleLinkedList <string> linkedList = new SimpleLinkedList <string>();

                linkedList.AddLast("asdf");

                linkedList.RemoveLast();

                Assert.Null(linkedList.Find("asdf"));
            }
コード例 #2
0
            public void RemoveLastMethod_SetsThe_LastProperty_ToTheSecondToLastNodeIfTheItemToBeRemovedIsTheTailOfTheList()
            {
                SimpleLinkedList <string> linkedList = new SimpleLinkedList <string>();

                linkedList.AddLast("new Item 1");
                linkedList.AddLast("new Item 2");

                linkedList.RemoveLast();

                Assert.Equal("new Item 1", linkedList.Last.Item);
            }
コード例 #3
0
            public void RemoveLastMethod_RemovesTheLastItemInTheList()
            {
                SimpleLinkedList <string> linkedList = new SimpleLinkedList <string>();

                linkedList.AddLast("asdf");
                linkedList.AddLast("qwer");

                linkedList.RemoveLast();

                Assert.NotEqual("qwer", linkedList.Last.Item);
            }
コード例 #4
0
            public void RemoveLastMethod_DecrementsLengthOfList()
            {
                SimpleLinkedList <string> linkedList = new SimpleLinkedList <string>();
                int expectedCount = 0;

                linkedList.AddFirst("asdf"); expectedCount++;
                linkedList.AddFirst("qwer"); expectedCount++;

                linkedList.RemoveLast(); expectedCount--;

                Assert.Equal(expectedCount, linkedList.Count);
            }
コード例 #5
0
            public void RemoveLastMethod_SetsThe_LastProperty_ToNullIfTheItemToBeRemovedIsTheOnlyItemInTheList()
            {
                SimpleLinkedList <string> linkedList = new SimpleLinkedList <string>();

                linkedList.AddLast("new Item 1");

                linkedList.RemoveLast();

                // acessing linkedList.Last throws exception if the tail of the list is null
                Assert.Throws <InvalidOperationException>(
                    delegate
                {
                    LinkedListNode <string> node = linkedList.Last;
                });
            }
コード例 #6
0
            public void RemoveLastMethod_SetsThe_LastProperty_ToTheSecondToLastNodeIfTheItemToBeRemovedIsTheTailOfTheList()
            {
                SimpleLinkedList<string> linkedList = new SimpleLinkedList<string>();
                linkedList.AddLast("new Item 1");
                linkedList.AddLast("new Item 2");

                linkedList.RemoveLast();

                Assert.Equal("new Item 1", linkedList.Last.Item);
            }
コード例 #7
0
            public void RemoveLastMethod_SetsThe_LastProperty_ToNullIfTheItemToBeRemovedIsTheOnlyItemInTheList()
            {
                SimpleLinkedList<string> linkedList = new SimpleLinkedList<string>();
                linkedList.AddLast("new Item 1");

                linkedList.RemoveLast();

                // acessing linkedList.Last throws exception if the tail of the list is null
                Assert.Throws<InvalidOperationException>(
                    delegate
                    {
                        LinkedListNode<string> node = linkedList.Last;
                    });
            }
コード例 #8
0
            public void RemoveLastMethod_RemovesTheOnlyItemInTheList()
            {
                SimpleLinkedList<string> linkedList = new SimpleLinkedList<string>();
                linkedList.AddLast("asdf");

                linkedList.RemoveLast();

                Assert.Null(linkedList.Find("asdf"));
            }
コード例 #9
0
            public void RemoveLastMethod_RemovesTheLastItemInTheList()
            {
                SimpleLinkedList<string> linkedList = new SimpleLinkedList<string>();
                linkedList.AddLast("asdf");
                linkedList.AddLast("qwer");

                linkedList.RemoveLast();

                Assert.NotEqual("qwer", linkedList.Last.Item);
            }
コード例 #10
0
            public void RemoveLastMethod_DecrementsLengthOfList()
            {
                SimpleLinkedList<string> linkedList = new SimpleLinkedList<string>();
                int expectedCount = 0;
                linkedList.AddFirst("asdf"); expectedCount++;
                linkedList.AddFirst("qwer"); expectedCount++;

                linkedList.RemoveLast(); expectedCount--;

                Assert.Equal(expectedCount, linkedList.Count);
            }