title: ASP.NET 5 Unit Test controller with UserManager
body: <p>I started to use ASP.NET 5 (vNext) and now I'm trying to unit test a controller that uses <strong>UserManager</strong> to register and login users. </p>
  
  <p>I'm using <strong>xUnit</strong> and <strong>moq.netcore</strong>. </p>
  
  <p>In my UnitTest I have:</p>
  
  <pre><code>var mockStore = new Mock&lt;IUserStore&lt;ApplicationUser&gt;&gt;(MockBehavior.Strict).As&lt;IUserPasswordStore&lt;ApplicationUser&gt;&gt;();
  
  mockStore.Setup(x =&gt; x.CreateAsync(It.IsAny&lt;ApplicationUser&gt;(), CancellationToken.None)).Returns(Task.FromResult(new IdentityResult()));
  
  var userManager = new UserManager&lt;ApplicationUser&gt;(mockStore.Object, null, null, null, null, null, null, null, null, null);
  </code></pre>
  
  <p>And the code in the controller:</p>
  
  <pre><code>var result = await _securityManager.CreateAsync(user, model.Password);
  </code></pre>
  
  <p>But, when I run the unit test I get a null exception, when calling CreateAsync. </p>
  
  <p>I don't understand why I can't Mock the CreateAsync method with ApplicationUser and string parameters, and I have to mock it with the CancellationToken. </p>
  
  <p>It's my first project using ASP.NET 5, I was using ASP.NET 4.6 before, so a lot of things are different now.</p>
  
  <p>And, do you think I should already develop an important project in ASP.NET 5 or should I wait and develop it for ASP.NET 4.6? </p>