title: Assert that a method is called to bring an if condition under test
body: <p>Here is an example where I am testing the line <code>if (true)</code>. But although the condition is obviously true, Moq tells me the method was never called.</p>
  
  <pre><code>    public class test
      {
          public virtual void start()
          {
              if (true)
                  called();
          }
  
          public virtual void called()
          {
  
          }
      }
  
      [Test]
      public void QuickTest()
      {
          var mock = new Mock&lt;test&gt;();
          mock.Object.start();
          mock.Verify(t =&gt; t.start(), "this works");
          mock.Verify(t =&gt; t.called(), "crash here: why not called?");
      }
  </code></pre>
  
  <p>How do I test that the method call to <code>called()</code> has happened?</p>
  
  <p>I thought Moq was the solution, but from the comments it looks like it isn't so I've made another example without any reference to Moq:</p>
  
  <pre><code>public class test
  {
      public bool condition = true;
  
      public test(bool cond)
      {
          condition = cond;
      }
  
      public virtual string start()
      {
          var str = "somestuff";
  
          if (condition)
              str += called();
  
          str += "something more";
          return str;
      }
  
      public virtual string called()
      {
          return "something more";
      }
  }
  
  [Test]
  public void ConditionTrue_CallsCalled()
  {
      var t = new test(true);
      t.start();
      //syntax? t.HasCalled("called");
      Assert.IsTrue(result.Contains("something more"));
  }
  
  [Test]
  public void ConditionFalse_NoCall()
  {
      var t = new test(false);
  
      t.start();
  
      //syntax? t.HasNotCalled("called");
      // Can't check this way because something more is already being added
      Assert.IsFalse(result.Contains("something more")); 
  }
  </code></pre>
  
  <p>Is it possible to do this? Is it worthwhile?</p>