title: "Run a method only if a condition is satisfied" pattern
body: <p>I have a method</p>
  
  <pre><code>using Microsoft.VisualStudio.TestTools.UnitTesting; // using visual studio's test framework
  
  [TestMethod]
  public void ATestMethod()
  {
      // stuff
  }
  </code></pre>
  
  <p>from a <code>public class ATestClass</code>. This test class runs two types of tests :</p>
  
  <ul>
  <li>tests requiring that a certain software is installed on the machine running the test</li>
  <li>tests that can run free</li>
  </ul>
  
  <p>To handle this, I added a <code>public class BaseTestClass</code> from which I made <code>ATestClass</code> derive, and in <code>ATestClass</code> I added a :</p>
  
  <pre><code>public bool isTheSoftwareInstalledOnTheMachine()
  {
      // stuff
  }
  </code></pre>
  
  <p>and I "decorated" all internal scopes of tests from <code>ATestClass</code> as follows :</p>
  
  <pre><code>[TestMethod]
  public void ATestMethod()
  {
      if (isTheSoftwareInstalledOnTheMachine())
      {
          // stuff
      }
  }
  </code></pre>
  
  <p>I find this horrible. I would rather like to be able to write something like :</p>
  
  <pre><code>[TestMethod]
  [RunIfTheSoftwareInstalledOnTheMachine]
  public void ATestMethod()
  {
      // stuff
  }
  </code></pre>
  
  <p>but I don't know if one is allowed to define "custom" <code>[characterizer]</code>'s. (I don't even know the right word for them.) If it is, would that be the best design ? (I heard about the decorator pattern, but I don't know if I could make it generic enough in my context, because I would potentially need to use the condition for many other test classes.) Anyway, how would I proceed with <code>characterizer</code>'s ?</p>