title: Unit test a controller with custom model binder
body: <p>In my application I have a custom model binder that I set to the DefaultBinder in the global.asax:</p>
  
  <pre><code> ModelBinders.Binders.DefaultBinder = new XLDataAnnotationsModelBinder();
  </code></pre>
  
  <p>When writing unit tests for controllers I need to make sure the controller uses the custom model binder but I don't know how to do this.</p>
  
  <p>My test looks like this:</p>
  
  <pre><code> [Test]
   public void Details_Post_Action_Fails_To_Change_Email_Address_With_Duplicate()
   {
       // Setup
       var controller = new AccountController();
       controller.SetFakeControllerContext();
  
       var param = Customer.Load(30005);
       param.EmailAddress = "foo@bar.com";
  
       // Test
       var result = controller.Details(param);
  
       // Assert
       Assert.IsTrue(result is ViewResult);  // will be ViewResult if failed....
       Assert.IsFalse(((ViewResult)result).ViewData.ModelState.IsValid);
   }
  </code></pre>
  
  <p>With this unit test the controller ends up using the DefaultModelBinder.  What can I add in this test to ensure the controller uses the custom model binder?</p>