diff --git a/src/Microsoft.AspNet.Identity/IdentityUser.cs b/src/Microsoft.AspNet.Identity/IdentityUser.cs index ce273deaae..1589199a77 100644 --- a/src/Microsoft.AspNet.Identity/IdentityUser.cs +++ b/src/Microsoft.AspNet.Identity/IdentityUser.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; namespace Microsoft.AspNet.Identity { @@ -86,20 +85,5 @@ namespace Microsoft.AspNet.Identity /// Used to record failures for the purposes of lockout /// public virtual int AccessFailedCount { get; set; } - - /// - /// Roles for the user - /// - public virtual ICollection> Roles { get; } = new List>(); - - /// - /// Claims for the user - /// - public virtual ICollection> Claims { get; } = new List>(); - - /// - /// Associated logins for the user - /// - public virtual ICollection> Logins { get; } = new List>(); } } diff --git a/test/Microsoft.AspNet.Identity.InMemory.Test/HttpSignInTest.cs b/test/Microsoft.AspNet.Identity.InMemory.Test/HttpSignInTest.cs index f9f871fdc8..81495de872 100644 --- a/test/Microsoft.AspNet.Identity.InMemory.Test/HttpSignInTest.cs +++ b/test/Microsoft.AspNet.Identity.InMemory.Test/HttpSignInTest.cs @@ -14,7 +14,7 @@ using Xunit; namespace Microsoft.AspNet.Identity.InMemory.Test { - public class ApplicationUser : IdentityUser { } + public class ApplicationUser : InMemoryUser { } public class HttpSignInTest { diff --git a/test/Microsoft.AspNet.Identity.InMemory.Test/InMemoryStoreTest.cs b/test/Microsoft.AspNet.Identity.InMemory.Test/InMemoryStoreTest.cs index e3de60ca21..9fbc2536dc 100644 --- a/test/Microsoft.AspNet.Identity.InMemory.Test/InMemoryStoreTest.cs +++ b/test/Microsoft.AspNet.Identity.InMemory.Test/InMemoryStoreTest.cs @@ -6,7 +6,7 @@ using Microsoft.Framework.DependencyInjection; namespace Microsoft.AspNet.Identity.InMemory.Test { - public class InMemoryStoreTest : UserManagerTestBase + public class InMemoryStoreTest : UserManagerTestBase { protected override object CreateTestContext() { @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Identity.InMemory.Test protected override void AddUserStore(IServiceCollection services, object context = null) { - services.AddSingleton, InMemoryUserStore>(); + services.AddSingleton, InMemoryUserStore>(); } protected override void AddRoleStore(IServiceCollection services, object context = null) diff --git a/test/Microsoft.AspNet.Identity.InMemory.Test/InMemoryUserStore.cs b/test/Microsoft.AspNet.Identity.InMemory.Test/InMemoryUserStore.cs index 3f6ef090d5..8d04d1ae4a 100644 --- a/test/Microsoft.AspNet.Identity.InMemory.Test/InMemoryUserStore.cs +++ b/test/Microsoft.AspNet.Identity.InMemory.Test/InMemoryUserStore.cs @@ -10,6 +10,30 @@ using System.Threading.Tasks; namespace Microsoft.AspNet.Identity.InMemory { + public class InMemoryUser : IdentityUser + { + public InMemoryUser() { } + + public InMemoryUser(string userName) : base(userName) { } + + + /// + /// Roles for the user + /// + public virtual ICollection Roles { get; } = new List(); + + /// + /// Claims for the user + /// + public virtual ICollection Claims { get; } = new List(); + + /// + /// Associated logins for the user + /// + public virtual ICollection Logins { get; } = new List(); + + } + public class InMemoryUserStore : IUserLoginStore, IUserRoleStore, @@ -21,7 +45,7 @@ namespace Microsoft.AspNet.Identity.InMemory IUserPhoneNumberStore, IQueryableUserStore, IUserTwoFactorStore - where TUser : IdentityUser + where TUser : InMemoryUser { private readonly Dictionary _logins = new Dictionary(); @@ -42,7 +66,7 @@ namespace Microsoft.AspNet.Identity.InMemory { foreach (var claim in claims) { - user.Claims.Add(new IdentityUserClaim { ClaimType = claim.Type, ClaimValue = claim.Value, UserId = user.Id }); + user.Claims.Add(new IdentityUserClaim { ClaimType = claim.Type, ClaimValue = claim.Value, UserId = user.Id }); } return Task.FromResult(0); } @@ -149,7 +173,7 @@ namespace Microsoft.AspNet.Identity.InMemory public virtual Task AddLoginAsync(TUser user, UserLoginInfo login, CancellationToken cancellationToken = default(CancellationToken)) { - user.Logins.Add(new IdentityUserLogin + user.Logins.Add(new IdentityUserLogin { UserId = user.Id, ProviderKey = login.ProviderKey, @@ -292,7 +316,7 @@ namespace Microsoft.AspNet.Identity.InMemory // RoleId == roleName for InMemory public Task AddToRoleAsync(TUser user, string role, CancellationToken cancellationToken = default(CancellationToken)) { - user.Roles.Add(new IdentityUserRole { RoleId = role, UserId = user.Id }); + user.Roles.Add(new IdentityUserRole { RoleId = role, UserId = user.Id }); return Task.FromResult(0); }