diff --git a/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/InMemoryEFUserStoreTest.cs b/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/InMemoryEFUserStoreTest.cs index 5b92dac77d..2566bf33db 100644 --- a/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/InMemoryEFUserStoreTest.cs +++ b/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/InMemoryEFUserStoreTest.cs @@ -17,13 +17,13 @@ namespace Microsoft.AspNet.Identity.EntityFramework.InMemory.Test protected override void AddUserStore(IServiceCollection services, object context = null) { - services.AddInstance>(new UserStore((InMemoryContext)context)); + services.AddSingleton>(new UserStore((InMemoryContext)context)); } protected override void AddRoleStore(IServiceCollection services, object context = null) { var store = new RoleStore((InMemoryContext)context); - services.AddInstance>(store); + services.AddSingleton>(store); } protected override IdentityUser CreateTestUser(string namePrefix = "", string email = "", string phoneNumber = "", diff --git a/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/TestIdentityFactory.cs b/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/TestIdentityFactory.cs index 9c79883be4..7057f09ea3 100644 --- a/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/TestIdentityFactory.cs +++ b/test/Microsoft.AspNet.Identity.EntityFramework.InMemory.Test/TestIdentityFactory.cs @@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Identity.EntityFramework.InMemory.Test public static RoleManager CreateRoleManager(InMemoryContext context) { var services = CreateTestServices(); - services.AddInstance>(new RoleStore(context)); + services.AddSingleton>(new RoleStore(context)); return services.BuildServiceProvider().GetRequiredService>(); } diff --git a/test/Microsoft.AspNet.Identity.EntityFramework.Test/SqlStoreTestBase.cs b/test/Microsoft.AspNet.Identity.EntityFramework.Test/SqlStoreTestBase.cs index e6830e8ebe..7f63c5e3c8 100644 --- a/test/Microsoft.AspNet.Identity.EntityFramework.Test/SqlStoreTestBase.cs +++ b/test/Microsoft.AspNet.Identity.EntityFramework.Test/SqlStoreTestBase.cs @@ -93,12 +93,12 @@ namespace Microsoft.AspNet.Identity.EntityFramework.Test protected override void AddUserStore(IServiceCollection services, object context = null) { - services.AddInstance>(new UserStore((TestDbContext)context)); + services.AddSingleton>(new UserStore((TestDbContext)context)); } protected override void AddRoleStore(IServiceCollection services, object context = null) { - services.AddInstance>(new RoleStore((TestDbContext)context)); + services.AddSingleton>(new RoleStore((TestDbContext)context)); } protected override void SetUserPasswordHash(TUser user, string hashedPassword) diff --git a/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreGuidKeyTest.cs b/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreGuidKeyTest.cs index abf46d4e71..a84b1e997f 100644 --- a/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreGuidKeyTest.cs +++ b/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreGuidKeyTest.cs @@ -50,12 +50,12 @@ namespace Microsoft.AspNet.Identity.EntityFramework.Test protected override void AddUserStore(IServiceCollection services, object context = null) { - services.AddInstance>(new ApplicationUserStore((TestDbContext)context)); + services.AddSingleton>(new ApplicationUserStore((TestDbContext)context)); } protected override void AddRoleStore(IServiceCollection services, object context = null) { - services.AddInstance>(new ApplicationRoleStore((TestDbContext)context)); + services.AddSingleton>(new ApplicationRoleStore((TestDbContext)context)); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreTest.cs b/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreTest.cs index 511736dfc9..4f4934d2e0 100644 --- a/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreTest.cs +++ b/test/Microsoft.AspNet.Identity.EntityFramework.Test/UserStoreTest.cs @@ -85,12 +85,12 @@ namespace Microsoft.AspNet.Identity.EntityFramework.Test protected override void AddUserStore(IServiceCollection services, object context = null) { - services.AddInstance>(new UserStore((IdentityDbContext)context)); + services.AddSingleton>(new UserStore((IdentityDbContext)context)); } protected override void AddRoleStore(IServiceCollection services, object context = null) { - services.AddInstance>(new RoleStore((IdentityDbContext)context)); + services.AddSingleton>(new RoleStore((IdentityDbContext)context)); } [ConditionalFact] diff --git a/test/Microsoft.AspNet.Identity.InMemory.Test/HttpSignInTest.cs b/test/Microsoft.AspNet.Identity.InMemory.Test/HttpSignInTest.cs index 64377debf0..cab788c421 100644 --- a/test/Microsoft.AspNet.Identity.InMemory.Test/HttpSignInTest.cs +++ b/test/Microsoft.AspNet.Identity.InMemory.Test/HttpSignInTest.cs @@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Identity.InMemory.Test contextAccessor.Setup(a => a.HttpContext).Returns(context.Object); var services = new ServiceCollection(); services.AddLogging(); - services.AddInstance(contextAccessor.Object); + services.AddSingleton(contextAccessor.Object); services.AddIdentity(); services.AddSingleton, InMemoryUserStore>(); services.AddSingleton, InMemoryRoleStore>(); diff --git a/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs b/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs index f23400ce86..4c39dc78a4 100644 --- a/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs @@ -55,9 +55,9 @@ namespace Microsoft.AspNet.Identity.Test signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id)).ReturnsAsync(user).Verifiable(); signInManager.Setup(s => s.CreateUserPrincipalAsync(user)).ReturnsAsync(principal).Verifiable(); var services = new ServiceCollection(); - services.AddInstance(options.Object); - services.AddInstance(signInManager.Object); - services.AddInstance(new SecurityStampValidator()); + services.AddSingleton(options.Object); + services.AddSingleton(signInManager.Object); + services.AddSingleton(new SecurityStampValidator()); httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider()); var ticket = new AuthenticationTicket(principal, @@ -89,9 +89,9 @@ namespace Microsoft.AspNet.Identity.Test contextAccessor.Object, claimsManager.Object, options.Object, null); signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id)).ReturnsAsync(null).Verifiable(); var services = new ServiceCollection(); - services.AddInstance(options.Object); - services.AddInstance(signInManager.Object); - services.AddInstance(new SecurityStampValidator()); + services.AddSingleton(options.Object); + services.AddSingleton(signInManager.Object); + services.AddSingleton(new SecurityStampValidator()); httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider()); var id = new ClaimsIdentity(identityOptions.Cookies.ApplicationCookieAuthenticationScheme); id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); @@ -124,9 +124,9 @@ namespace Microsoft.AspNet.Identity.Test contextAccessor.Object, claimsManager.Object, options.Object, null); signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id)).ReturnsAsync(null).Verifiable(); var services = new ServiceCollection(); - services.AddInstance(options.Object); - services.AddInstance(signInManager.Object); - services.AddInstance(new SecurityStampValidator()); + services.AddSingleton(options.Object); + services.AddSingleton(signInManager.Object); + services.AddSingleton(new SecurityStampValidator()); httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider()); var id = new ClaimsIdentity(identityOptions.Cookies.ApplicationCookieAuthenticationScheme); id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); @@ -160,9 +160,9 @@ namespace Microsoft.AspNet.Identity.Test signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id)).Throws(new Exception("Shouldn't be called")); signInManager.Setup(s => s.SignInAsync(user, false, null)).Throws(new Exception("Shouldn't be called")); var services = new ServiceCollection(); - services.AddInstance(options.Object); - services.AddInstance(signInManager.Object); - services.AddInstance(new SecurityStampValidator()); + services.AddSingleton(options.Object); + services.AddSingleton(signInManager.Object); + services.AddSingleton(new SecurityStampValidator()); httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider()); var id = new ClaimsIdentity(identityOptions.Cookies.ApplicationCookieAuthenticationScheme); id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id)); diff --git a/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs b/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs index 4b0330700c..4f03f43a3c 100644 --- a/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs @@ -37,8 +37,8 @@ namespace Microsoft.AspNet.Identity.Test // contextAccessor.Setup(a => a.Value).Returns(context); // app.UseServices(services => // { - // services.AddInstance(contextAccessor.Object); - // services.AddInstance(new Nulllogger()); + // services.AddSingleton(contextAccessor.Object); + // services.AddSingleton(new Nulllogger()); // services.AddIdentity(s => // { // s.AddUserStore(() => new InMemoryUserStore()); diff --git a/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs b/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs index 580b5e2987..6f132068d7 100644 --- a/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs +++ b/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs @@ -1413,8 +1413,8 @@ namespace Microsoft.AspNet.Identity.Test var services = new ServiceCollection(); var store = new Mock>(); var describer = new TestErrorDescriber(); - services.AddInstance(describer) - .AddInstance>(store.Object) + services.AddSingleton(describer) + .AddSingleton>(store.Object) .AddIdentity(); services.AddLogging(); services.AddSingleton(); diff --git a/test/Shared/UserManagerTestBase.cs b/test/Shared/UserManagerTestBase.cs index c0de1ea4e1..4fcd82cd50 100644 --- a/test/Shared/UserManagerTestBase.cs +++ b/test/Shared/UserManagerTestBase.cs @@ -44,8 +44,8 @@ namespace Microsoft.AspNet.Identity.Test AddUserStore(services, context); AddRoleStore(services, context); services.AddLogging(); - services.AddInstance>>(new TestLogger>()); - services.AddInstance>>(new TestLogger>()); + services.AddSingleton>>(new TestLogger>()); + services.AddSingleton>>(new TestLogger>()); } protected virtual UserManager CreateManager(object context = null, IServiceCollection services = null, Action configureServices = null)