0

I use Net.Core 2.1 I want to create UserManager instance in my Unit-Tests Project. In my API inject my dependency like:

services.AddIdentity<User, IdentityRole<string>>()
                .AddEntityFrameworkStores<MyDbContext>()
                .AddDefaultTokenProviders();

But how to create UserManager instance in Tests Project?

Vasiliy Terkin
  • 165
  • 2
  • 15
  • 1
    https://stackoverflow.com/questions/37724738/how-to-unit-test-asp-net-core-application-with-constructor-dependency-injection – Salah Akbari Oct 04 '18 at 08:41
  • 3
    The answer is: **not at all**. Unit Tests are about testing a small piece of code, usually as little as a method call or class initialization (called unit). No dependencies are used at all, mocks at best to fake results of depending services in order to test a specific case. Real dependencies are only used in **integration tests**. your code needs to be abstracted properly and designed to play well with unit tests – Tseng Oct 04 '18 at 10:28
  • yeap, i mean integration tests. – Vasiliy Terkin Oct 05 '18 at 12:53

0 Answers0