title: Model missing when unit testing MVC 5 async controller methods
body: <p>Here is my controller method:</p>
  
  <pre><code>private IAutoManagerUnitOfWork _work;
  
  public VehiclesController(IAutoManagerUnitOfWork work)
  {
      _work = work;
  }
  
  public async Task&lt;ViewResult&gt; Index()
  {
      return View("Index", await _work.VehicleRepository.GetAll().ToListAsync());
  }
  </code></pre>
  
  <p>Here is my NUnit test method:</p>
  
  <pre><code>[Test]
  public async Task Index_Get_ReturnsViewResult()
  {
      MockUnitOfWork uow = new MockUnitOfWork();
      uow.VehicleRepository.Add(new Vehicle { Year = 2011, Make = "Ford", Model = "Mustang", Trim = "GT" });
  
      var controller = new VehiclesController(uow);
  
      ViewResult viewResult = await controller.Index();
  
      var model = (List&lt;Vehicle&gt;)(viewResult.Model);
      Assert.IsTrue(model.Count &gt; 0); // Causes exception because model isn't defined.
  }
  </code></pre>
  
  <p>When I step through the test, viewResult.Model is empty (has a Count = 0). I've tried making my test method non-async and doing a task.Wait() after the call to Index(), but the only way I can get it to work is by changing my controller method to a non-async method. I found a couple of examples here on Stack Overflow, but even following those I can't get it to work. What am I doing wrong?</p>