title: Testing Remove method without a call to Add method
body: <p>I am writing test for a class thats manage trees of Tag objects:</p>
  
  <pre><code>public class Tag
  {
      public virtual int Id { get; set; }
      public virtual string Description{ get; set; }
      private IList&lt;Tag&gt; children = new List&lt;Tag&gt;();
      public virtual IEnumerable&lt;Tag&gt; Children
      {
          get {return children .ToArray();}
      }
      public void AddChildTag(Tag child)
      {
          children.Add(child);
      }
      public void RemoveChildTag(Tag child)
      {
          children.Remove(child);
      }
  }
  </code></pre>
  
  <p>As you can see the only mode to set the parent property is via the <code>AddChildTag</code> method and this is exactly what i want, my problem is in unit test: since every test should be atomic, how can i test the <code>RemoveChildTag</code> method?</p>
  
  <p>Only way i see is a call to the add method and later to the remove, but in this way if Add as some errors, even the test of remove will fail, so atomicity is lost.</p>
  
  <p>How can that be done?</p>
  
  <p><strong>EDIT</strong><br>
  I removed parent property from Tag object, since i no more use it
  Some test according to solution using NUnit and FluentAssertion</p>
  
  <pre><code>    [Test]
      public void AddChildTagAddsChildren()
      {
          //Arrange
          Tag parent = new Tag();
          Tag child = new Tag();
          //Act
          parent.AddChildTag(child);
          //Assert
          parent.Children.Should().Contain(child);
      }
      [Test]
      public void RemoveChildTagRemovesAddedChildren()
      {
          //Arrange
          Tag parent = new Tag();
          Tag child = new Tag();
          parent.AddChildTag(child);
          //Act
          parent.RemoveChildTag(child);
          //Assert
          parent.Children.Should().NotContain(child);
      }
      [Test]
      public void RemoveChildTagThrowsNothingWhenNoChild()
      {
          //Arrange
          Tag parent= new Tag();
          Tag child= new Tag();
          //Act
          Action RemoveChild = () =&gt; parent.RemoveChildTag(child);
          //Assert
          RemoveChild.ShouldNotThrow();
      }
  </code></pre>