Exemplo n.º 1
0
        public void CheckIfContainsWorksCorrectly2()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(3);
            linkedList.Add(2);
            linkedList.Add(1);
            Assert.False(linkedList.Contains(4));
        }
Exemplo n.º 2
0
        public void CheckIfAddAfterWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(3);
            linkedList.AddAfter(linkedList.Find(1), 2);
            Assert.Equal(2, linkedList.Find(1).NextLink.Value);
        }
Exemplo n.º 3
0
        public void CheckIfAddFirstWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(2);
            linkedList.Add(3);
            linkedList.AddFirst(1);
            Assert.Equal(1, linkedList.Find(2).PreviousLink.Value);
        }
Exemplo n.º 4
0
        public void CheckIfAddBeforeArgumentNullExceptionWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            Assert.Throws <ArgumentNullException>(() => linkedList.AddBefore(null, 2));
        }
Exemplo n.º 5
0
        public void CheckIfRemoveLastReadonlyExceptionWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            linkedList.MakeReadOnly();
            Assert.Throws <NotSupportedException>(() => linkedList.RemoveLast());
        }
Exemplo n.º 6
0
        public void CheckIfAddBeforeExceptionReadOnlyWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            linkedList.MakeReadOnly();
            Assert.Throws <NotSupportedException>(() => linkedList.AddBefore(linkedList.Find(3), 2));
        }
Exemplo n.º 7
0
        public void CheckIfRemoveLastWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            linkedList.RemoveLast();
            Assert.Equal(null, linkedList.Find(3));
        }
Exemplo n.º 8
0
        public void CheckIfRemoveWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            linkedList.Remove(2);
            Assert.Equal(3, linkedList.Find(1).NextLink.Value);
        }
Exemplo n.º 9
0
        public void CheckIfCopyToNotEnoughSpaceExceptionWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            var array = new int[3];

            Assert.Throws <ArgumentException>(() => linkedList.CopyTo(array, 1));
        }
Exemplo n.º 10
0
        public void CheckIfCopyToIndexSmallerThanZeroExceptionWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            var array = new int[20];

            Assert.Throws <ArgumentOutOfRangeException>(() => linkedList.CopyTo(array, -10));
        }
Exemplo n.º 11
0
        public void CheckIfAddBeforeInvalidOperationExceptionWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            var newLink = new DataStructures.DoubleLink <int>(5);

            Assert.Throws <InvalidOperationException>(() => linkedList.AddBefore(newLink, 2));
        }
Exemplo n.º 12
0
        public void CheckIfEqualsWorksCorrectly1()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            var equalObject = linkedList;

            Assert.True(linkedList.Equals(equalObject));
        }
Exemplo n.º 13
0
        public void CheckIfFindLastWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            linkedList.Add(1);
            linkedList.Add(2);
            linkedList.Add(3);
            const int i = 2;

            linkedList.Add(i);
            Assert.Equal(linkedList.Find(2).NextLink.NextLink, linkedList.FindLast(2));
        }
Exemplo n.º 14
0
        public void CheckIfRemoveLastEmptyExceptionWorksCorrectly()
        {
            var linkedList = new DataStructures.DoubleLinkedListCollection <int>();

            Assert.Throws <InvalidOperationException>(() => linkedList.RemoveLast());
        }