I am trying to unit test this controller method, which comes out of the box in current MVC projects.
[AllowAnonymous]
public async Task C
Disclaimer: I work at Typemock.
Actually you don't need any interface if you are using Typemock, you just need to fake the IdentityResult you require and change the behavior of the asynchronous method "ConfirmEmailAsync", for example a test that checks the scenario of an Unconfirmed email:
[TestMethod, Isolated]
public async Task TestWhenEmailIsBad_ErrorMessageIsShown()
{
// Arrange
// Create the wanted controller for testing and fake IdentityResult
var controller = new aspdotNetExample.Controllers.AccountController();
var fakeIdentityRes = Isolate.Fake.Instance();
// Fake HttpContext to return a fake ApplicationSignInManager
var fakeSIM = Isolate.WhenCalled(() => controller.UserManager).ReturnRecursiveFake();
// Modifying the behavior of ConfirmEmailAsync to return fakeIdentityRes
Isolate.WhenCalled(() => fakeSIM.ConfirmEmailAsync("", "")).WillReturn(Task.FromResult(fakeIdentityRes));
Isolate.WhenCalled(() => fakeIdentityRes.Succeeded).WillReturn(false);
// Act
var result = await controller.ConfirmEmail("", "") as ViewResult;
// Assert
Assert.AreEqual("Error", result.ViewName);
}