How to test model binder in ASP.Net MVC 6?
<p>I'm trying to write a unit test for a custom model binder in ASP.Net MVC 6. It seems simple enough. The model binder has a single <code>BindModelAsync</code> method which takes a <code>ModelBindingContext</code> parameter.</p>

<p>In my unit test, I'm trying to figure out how to fake the <code>ModelBindingContext</code>. At first, I thought I could use the default constructor and set the properties on the object that I need. This works for all of the properties except <code>ModelType</code> which is not settable.</p>

<p>I then looked at the static <code>ModelBindingContext.CreateBindingContext</code> but it takes a bunch of scary looking parameters. Looking at <a href="https://github.com/aspnet/Mvc/blob/c116a38c87ef7a32f40659d393cae25677dfbdbd/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/HeaderModelBinderTests.cs#L119" rel="noreferrer">how some of the model binding tests</a> within the MVC repo are written, it seems like it is not possible for me to mock the <code>ModelBindingContext.ModelType</code> (unless maybe I copy/paste those 6 classes from <a href="https://github.com/aspnet/Mvc/blob/dev/test/Microsoft.AspNetCore.Mvc.TestCommon/TestModelMetadataProvider.cs" rel="noreferrer">Microsoft.AspNetCore.Mvc.TestCommon</a>).</p>

<p>Is there something simple/easy I am missing?</p>