Пример #1
0
        public void AddFirstToEmptyElemADTListHeadTailTest()
        {
            // Arrange
            var emptyList = new ADTList <int>();

            // Act
            emptyList.AddFirst(5);
            // Assert
            Assert.AreSame(emptyList.Head, emptyList.Tail);
        }
Пример #2
0
        public void AddLastToOneElemADTListCountTest()
        {
            // Arrange
            var emptyList = new ADTList <int>();

            // Act
            emptyList.AddLast(5).AddLast(6);
            // Assert
            Assert.AreEqual(2, emptyList.Count);
        }
Пример #3
0
        public void AddFirstToEmptyElemADTListCountTest()
        {
            // Arrange
            var emptyList = new ADTList <int>();

            // Act
            emptyList.AddFirst(5);
            // Assert
            Assert.AreEqual(1, emptyList.Count);
        }
Пример #4
0
        public void EmptyADTListCountTest()
        {
            // Arrange
            var emptyList = new ADTList <int>();

            // Act

            // Assert
            Assert.AreEqual(0, emptyList.Count);
        }
Пример #5
0
        public void AddLastToEmptyADTListHeadTailTest()
        {
            // Arrange
            var emptyList = new ADTList <int>();

            // Act
            emptyList.AddLast(5);
            // Assert
            Assert.AreNotEqual(null, emptyList.Head);
            Assert.AreSame(emptyList.Head, emptyList.Tail);
        }
Пример #6
0
        public void AddLastToOneElemADTListHeadTailTest()
        {
            // Arrange
            var emptyList = new ADTList <int>();

            // Act
            emptyList.AddLast(5).AddLast(6);
            // Assert
            Assert.AreNotSame(emptyList.Head, emptyList.Tail);
            Assert.AreSame(emptyList.Head, emptyList.Tail.Previous);
            Assert.AreSame(emptyList.Head.Next, emptyList.Tail);
        }
Пример #7
0
        public void DeleteFirstOneElemADTListHeadTailCountTest()
        {
            // Arrange
            var emptyList = new ADTList <int>().AddLast(1);

            // Act
            emptyList.DeleteFirst();
            // Assert
            Assert.AreEqual(null, emptyList.Head);
            Assert.AreEqual(null, emptyList.Tail);
            Assert.AreEqual(0, emptyList.Count);
        }
Пример #8
0
        public void DeleteFirstTwoElemADTListHeadTailCountTest()
        {
            // Arrange
            var emptyList = new ADTList <int>().AddLast(1).AddLast(2);

            // Act
            emptyList.DeleteFirst();
            // Assert
            Assert.AreSame(emptyList.Head, emptyList.Tail);
            Assert.AreEqual(2, emptyList.Head.Data);
            Assert.AreEqual(2, emptyList.Tail.Data);
            Assert.AreEqual(1, emptyList.Count);
        }
Пример #9
0
        public void DeleteSelectedNodeInADTListTest()
        {
            // Arrange
            var emptyList = new ADTList <int>();

            for (int i = 1; i < 5; i++)
            {
                emptyList.AddLast(i);
            }
            // Act
            emptyList.DeleteSelected(3);
            // Assert
            Assert.AreEqual(2, emptyList.Tail.Previous.Data);
            Assert.AreSame(emptyList.Tail, emptyList.Head.Next.Next);
        }
Пример #10
0
        public void FindMinimumReverseOrderNodeInADTListTest()
        {
            // Arrange
            var emptyList = new ADTList <int>();

            for (int i = 1; i < 5; i++)
            {
                emptyList.AddLast(i);
            }
            // Act
            ADTList <int> .Node n = emptyList.FindMinimum(
                Comparer <int> .Create(
                    (x, y) => (x < y) ? 1 : (x > y) ? -1 : 0)
                );

            // Assert
            Assert.AreEqual(4, n.Data);
        }