Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's probably a change in implementation of <code>System.Web.Mvc.JsonValueProviderFactory.GetValueProvider</code> that is hitting a value in <code>ControllerContext</code> that is null.</p> <p>You may need to mock an additional value in <code>ControllerContext</code>.</p> <p>At least that's where I'd look first.</p> <p>EDIT</p> <p>Yeah, looks like it's doing a null check on <code>controllerContext</code>. </p> <pre><code>public override IValueProvider GetValueProvider(ControllerContext controllerContext) { if (controllerContext == null) { throw new ArgumentNullException("controllerContext"); } object deserializedObject = GetDeserializedObject(controllerContext); if (deserializedObject == null) { return null; } Dictionary&lt;string, object&gt; backingStore = new Dictionary&lt;string, object&gt;(StringComparer.OrdinalIgnoreCase); AddToBackingStore(backingStore, string.Empty, deserializedObject); return new DictionaryValueProvider&lt;object&gt;(backingStore, CultureInfo.CurrentCulture); } </code></pre> <p>From the stacktrace we can see that <code>TryUpdateModel[TModel](TModel model, String prefix)</code>. Using reflector, it is accessing the <code>ControllerBase</code> <code>ValueProvider</code> property. This in turn calls <code>ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext)</code> with the current Controllers <code>ControllerContext</code> property.</p> <p>You should just be able to create a new <code>ControllerContext</code> instance and set the controller's property accordingly...</p> <pre><code>[TestMethod] public void EditTest { var controller = new Controller(); var controllerContext = new ControllerContext(); controller.ControllerContext = controllerContext; controller.Edit(...); } </code></pre> <p>Some additional mocking may be required to get it to fully function though. Some info on how to fully mock ControllerContext: <a href="https://stackoverflow.com/questions/32640/mocking-asp-net-mvc-controller-context">Mocking Asp.net-mvc Controller Context</a> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload