Mocking new Microsoft Entity Framework Identity UserManager and RoleManager

asp.net-identity c# entity-framework moq unit-testing

Accepted Answer

ZZZ_tmp
37
4/23/2018 1:42:42 PM

Popular Answer

For those who use the asp.net core framework, I'd want to revise the answer to the following query:

    private Mock<UserManager<ApplicationUser>> GetMockUserManager()
    {
        var userStoreMock = new Mock<IUserStore<ApplicationUser>>();
        return new Mock<UserManager<ApplicationUser>>(
            userStoreMock.Object, null, null, null, null, null, null, null, null);
    }

Yes, 8 times null, but there isn't a more elegant approach at this time. Look at the code source if you're interested in the other settings.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow