public void Remove_ThrowsForReferenceNotInitialized()
    {
        // Arrange
        var reference = new IntermediateNodeReference();

        // Act & Assert
        var exception = Assert.Throws <InvalidOperationException>(() => reference.Remove());

        Assert.Equal("The reference is invalid. References initialized with the default constructor cannot modify nodes.", exception.Message);
    }
    public void Remove_ThrowsForNodeNotFound()
    {
        // Arrange
        var parent = new BasicIntermediateNode("Parent");

        var node1 = new BasicIntermediateNode("Node1");

        var reference = new IntermediateNodeReference(parent, node1);

        // Act & Assert
        var exception = Assert.Throws <InvalidOperationException>(() => reference.Remove());

        Assert.Equal("The reference is invalid. The node 'Node1' could not be found as a child of 'Parent'.", exception.Message);
    }
    public void Remove_ThrowsForReadOnlyCollection()
    {
        // Arrange
        var parent = new BasicIntermediateNode("Parent", IntermediateNodeCollection.ReadOnly);

        var node1 = new BasicIntermediateNode("Node1");

        var reference = new IntermediateNodeReference(parent, node1);

        // Act & Assert
        var exception = Assert.Throws <InvalidOperationException>(() => reference.Remove());

        Assert.Equal("The node 'Parent' has a read-only child collection and cannot be modified.", exception.Message);
    }
    public void Remove_RemovesNode()
    {
        // Arrange
        var parent = new BasicIntermediateNode("Parent");

        var node1 = new BasicIntermediateNode("Node1");
        var node2 = new BasicIntermediateNode("Node2");
        var node3 = new BasicIntermediateNode("Node3");

        parent.Children.Add(node1);
        parent.Children.Add(node3);
        parent.Children.Add(node2);

        var reference = new IntermediateNodeReference(parent, node3);

        // Act
        reference.Remove();

        // Assert
        Assert.Equal(new[] { node1, node2, }, parent.Children);
    }