title: What Should a Custom Assert Class Do if the Assert Fails?
body: <p>I created a custom Assert class for unit testing, and I'm not sure what to do when I want to notify that the test has failed:</p>
  
  
  
  <pre class="lang-c# prettyprint-override"><code>public static class MyAssert
  {
      public static void Contains(File file, string text){
          if(!ContainText(file, text)){
              // what to do here?
          }
      }
  }
  </code></pre>
  
  <p>I reflected the <code>Microsoft.VisualStudio.TestTools.UnitTesting.Assert</code> Class and noticed that it calls HandleFail:</p>
  
  <pre class="lang-c# prettyprint-override"><code>internal static void HandleFail(string assertionName, string message, params object[] parameters)
  {
    string str = string.Empty;
    if (!string.IsNullOrEmpty(message))
      str = parameters != null ? string.Format((IFormatProvider) CultureInfo.CurrentCulture, Assert.ReplaceNulls((object) message), parameters) : Assert.ReplaceNulls((object) message);
    if (Assert.AssertionFailure != null)
      Assert.AssertionFailure((object) null, EventArgs.Empty);
    throw new AssertFailedException((string) FrameworkMessages.AssertionFailed((object) assertionName, (object) str));
  }
  </code></pre>
  
  <p>But this is an internal method.  I could use reflection to call it, or maybe it makes more sense to throw an AssertFailedException?  Is there another option that I'm missing?</p>