title: Testing MVC Controller Action HttpAcceptAttribute Verbs
body: <p>What is the best way to unit test the controller action HttpAcceptAttribute verbs?</p>
  
  <p>So far I have the following but it's so ugly even a mother couldn't love it and not very flexible. Is there a better way?</p>
  
  <pre><code>[Fact] // using xUnit, mocking controller in class
  public void FilterControllerTestRemoveFilterByProductAttributeIsOfTypePost()
  {
      Type[] paramTypes = new[] { typeof(int) };
      var method = typeof(FilterController).GetMethod("MyMethod", paramTypes);
  
      var attributes = method.GetCustomAttributes(typeof(AcceptVerbsAttribute), false).Cast&lt;AcceptVerbsAttribute&gt;().SingleOrDefault();
      Assert.NotNull(attributes);
      Assert.Equal(1, attributes.Verbs.Count());
      Assert.True(attributes.Verbs.First().Equals(HttpVerbs.Post.ToString(), StringComparison.InvariantCultureIgnoreCase));
  }
  </code></pre>
  
  <p>Thanks
  Mac</p>