1
Vote

AddBefore of DoublyLinkedList throws NullReferenceException

description

1.
public void AddBeforeThrowsNullReferenceException6181281577058()
    {
        DoublyLinkedList<int> doublyLinkedList;
        doublyLinkedList = new DoublyLinkedList<int>();
        doublyLinkedList.AddLast(0);
        DoublyLinkedListNode<int> s0 = new DoublyLinkedListNode<int>(0);
        s0.Next = (DoublyLinkedListNode<int>)null;
        s0.Previous = (DoublyLinkedListNode<int>)null;
        doublyLinkedList.AddBefore(s0, 0);
    }
 
 
2.
 
public void AddBefore101281577058()
    {
        DoublyLinkedList<int> doublyLinkedList;
        doublyLinkedList = new DoublyLinkedList<int>();
        doublyLinkedList.AddLast(0);
        DoublyLinkedListNode<int> s0 = new DoublyLinkedListNode<int>(0);
        s0.Next = (DoublyLinkedListNode<int>)null;
        s0.Previous = (DoublyLinkedListNode<int>)null;
        doublyLinkedList.AddBefore(s0, 0);
        Assert.IsNotNull((object)doublyLinkedList);
        Assert.IsNotNull(doublyLinkedList.Head);
        Assert.AreEqual<int>(0, doublyLinkedList.Head.Value);
        Assert.IsNotNull(doublyLinkedList.Head.Next);
        Assert.AreEqual<int>(0, doublyLinkedList.Head.Next.Value);
        Assert.IsNull(doublyLinkedList.Head.Next.Next);
        Assert.IsNotNull(doublyLinkedList.Head.Next.Previous);
        Assert.IsTrue(object.ReferenceEquals
                          (doublyLinkedList.Head.Next.Previous, doublyLinkedList.Head));
        Assert.IsNull(doublyLinkedList.Head.Previous);
        Assert.IsNotNull(doublyLinkedList.Tail);
        Assert.IsTrue
            (object.ReferenceEquals(doublyLinkedList.Tail, doublyLinkedList.Head.Next));
        Assert.AreEqual<bool>
            (false, ((CollectionBase<int>)doublyLinkedList).IsSynchronized);
        Assert.AreEqual<int>(2, ((CollectionBase<int>)doublyLinkedList).Count);
    }

comments