Inside my tests, here is my code:
[SetUp]
public void Initialise()
{
mockOwinManager = new Mock<IOwinManager<ApplicationUser, ApplicationRole>>();
mockSearch = new Mock<ISearch<ApplicationUser>>();
mockMail = new Mock<IRpdbMail>();
mockUserStore = new Mock<IUserStore<ApplicationUser>>();
mockOwinManager.Setup(x => x.UserManager).Returns(() => new AppUserManager(mockUserStore.Object));
sut = new UsersController(mockOwinManager.Object, mockSearch.Object, mockMail.Object);
}
And then the test itself:
[Test]
public void WhenPut_IfUserIsNullReturnInternalServerError()
{
mockOwinManager.Setup(x => x.UserManager.FindByIdAsync(It.IsAny<string>())).Returns(() => null);
var response = sut.Put(new AppPersonUpdate());
Assert.AreEqual(response.Result.StatusCode, HttpStatusCode.InternalServerError);
}
But my placement string causes the following error:
Can not instantiate proxy of class: Microsoft.AspNet.Identity.UserManager`1[[SWDB.BusinessLayer.Identity.ApplicationUser, SWDB.BusinessLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
Could not find a parameterless constructor.
Why is this so, since in the installer I set the matchOwinManager UserManager property in what I would like to return?
thanks
source
share