Switch to KRunner add initial DI unit test
This commit is contained in:
parent
ed31f6b019
commit
e40777cc6b
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"sources": ["src"]
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Identity
|
namespace Microsoft.AspNet.Identity
|
||||||
|
|
@ -5,14 +6,18 @@ namespace Microsoft.AspNet.Identity
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to validate a user
|
/// Used to validate a user
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="TUser"></typeparam>
|
||||||
public interface IUserValidator<in T>
|
/// <typeparam name="TKey"></typeparam>
|
||||||
|
public interface IUserValidator<TUser, TKey>
|
||||||
|
where TUser : class, IUser<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validate the user
|
/// Validate the user
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="manager"></param>
|
||||||
/// <param name="user"></param>
|
/// <param name="user"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IdentityResult> Validate(T user);
|
Task<IdentityResult> Validate(UserManager<TUser, TKey> manager, TUser user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -36,11 +36,11 @@ namespace Microsoft.AspNet.Identity
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("serviceProvider");
|
throw new ArgumentNullException("serviceProvider");
|
||||||
}
|
}
|
||||||
Store = serviceProvider.GetService<IUserStore<TUser, TKey>>();
|
|
||||||
ClaimsIdentityFactory = serviceProvider.GetService<IClaimsIdentityFactory<TUser, TKey>>();
|
|
||||||
PasswordHasher = serviceProvider.GetService<IPasswordHasher>();
|
PasswordHasher = serviceProvider.GetService<IPasswordHasher>();
|
||||||
UserValidator = serviceProvider.GetService<IUserValidator<TUser>>();
|
UserValidator = serviceProvider.GetService<IUserValidator<TUser, TKey>>();
|
||||||
PasswordValidator = serviceProvider.GetService<IPasswordValidator>();
|
PasswordValidator = serviceProvider.GetService<IPasswordValidator>();
|
||||||
|
//TODO: Store = serviceProvider.GetService<IUserStore<TUser, TKey>>();
|
||||||
|
//TODO: ClaimsIdentityFactory = serviceProvider.GetService<IClaimsIdentityFactory<TUser, TKey>>();
|
||||||
// TODO: maybe each optional store as well? Email and SMS services?
|
// TODO: maybe each optional store as well? Email and SMS services?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.AspNet.Identity
|
||||||
throw new ArgumentNullException("store");
|
throw new ArgumentNullException("store");
|
||||||
}
|
}
|
||||||
Store = store;
|
Store = store;
|
||||||
UserValidator = new UserValidator<TUser, TKey>(this);
|
UserValidator = new UserValidator<TUser, TKey>();
|
||||||
PasswordHasher = new PasswordHasher();
|
PasswordHasher = new PasswordHasher();
|
||||||
//TODO: ClaimsIdentityFactory = new ClaimsIdentityFactory<TUser, TKey>();
|
//TODO: ClaimsIdentityFactory = new ClaimsIdentityFactory<TUser, TKey>();
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +89,7 @@ namespace Microsoft.AspNet.Identity
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to validate users before persisting changes
|
/// Used to validate users before persisting changes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IUserValidator<TUser> UserValidator { get; set; }
|
public IUserValidator<TUser, TKey> UserValidator { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to validate passwords before persisting changes
|
/// Used to validate passwords before persisting changes
|
||||||
|
|
@ -322,7 +322,7 @@ namespace Microsoft.AspNet.Identity
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IdentityResult> ValidateUserInternal(TUser user) {
|
private async Task<IdentityResult> ValidateUserInternal(TUser user) {
|
||||||
return (UserValidator == null) ? IdentityResult.Success : await UserValidator.Validate(user).ConfigureAwait(false);
|
return (UserValidator == null) ? IdentityResult.Success : await UserValidator.Validate(this, user).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
#if NET45
|
#if NET45
|
||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
#endif
|
#endif
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Identity
|
namespace Microsoft.AspNet.Identity
|
||||||
|
|
@ -14,22 +14,17 @@ namespace Microsoft.AspNet.Identity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TUser"></typeparam>
|
/// <typeparam name="TUser"></typeparam>
|
||||||
/// <typeparam name="TKey"></typeparam>
|
/// <typeparam name="TKey"></typeparam>
|
||||||
public class UserValidator<TUser, TKey> : IUserValidator<TUser>
|
/// <typeparam name="TManager"></typeparam>
|
||||||
|
public class UserValidator<TUser, TKey> : IUserValidator<TUser, TKey>
|
||||||
where TUser : class, IUser<TKey>
|
where TUser : class, IUser<TKey>
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="manager"></param>
|
public UserValidator()
|
||||||
public UserValidator(UserManager<TUser, TKey> manager)
|
|
||||||
{
|
{
|
||||||
if (manager == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("manager");
|
|
||||||
}
|
|
||||||
AllowOnlyAlphanumericUserNames = true;
|
AllowOnlyAlphanumericUserNames = true;
|
||||||
Manager = manager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -42,24 +37,27 @@ namespace Microsoft.AspNet.Identity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool RequireUniqueEmail { get; set; }
|
public bool RequireUniqueEmail { get; set; }
|
||||||
|
|
||||||
private UserManager<TUser, TKey> Manager { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates a user before saving
|
/// Validates a user before saving
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="manager"></param>
|
||||||
|
/// <param name="user"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual async Task<IdentityResult> Validate(TUser item)
|
public virtual async Task<IdentityResult> Validate(UserManager<TUser, TKey> manager, TUser user)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (manager == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("item");
|
throw new ArgumentNullException("manager");
|
||||||
|
}
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("user");
|
||||||
}
|
}
|
||||||
var errors = new List<string>();
|
var errors = new List<string>();
|
||||||
await ValidateUserName(item, errors);
|
await ValidateUserName(manager, user, errors);
|
||||||
if (RequireUniqueEmail)
|
if (RequireUniqueEmail)
|
||||||
{
|
{
|
||||||
await ValidateEmail(item, errors);
|
await ValidateEmail(manager, user, errors);
|
||||||
}
|
}
|
||||||
if (errors.Count > 0)
|
if (errors.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -68,20 +66,60 @@ namespace Microsoft.AspNet.Identity
|
||||||
return IdentityResult.Success;
|
return IdentityResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ValidateUserName(TUser user, List<string> errors)
|
/// <summary>
|
||||||
|
/// Returns true if the character is a digit between '0' and '9'
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool IsDigit(char c)
|
||||||
|
{
|
||||||
|
return c >= '0' && c <= '9';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the character is between 'a' and 'z'
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool IsLower(char c)
|
||||||
|
{
|
||||||
|
return c >= 'a' && c <= 'z';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the character is between 'A' and 'Z'
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool IsUpper(char c)
|
||||||
|
{
|
||||||
|
return c >= 'A' && c <= 'Z';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the character is upper, lower, or a digit
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool IsAlphaNumeric(char c)
|
||||||
|
{
|
||||||
|
return IsUpper(c) || IsLower(c) || IsDigit(c) || c == '@' || c == '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ValidateUserName(UserManager<TUser, TKey> manager, TUser user, ICollection<string> errors)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(user.UserName))
|
if (string.IsNullOrWhiteSpace(user.UserName))
|
||||||
{
|
{
|
||||||
errors.Add(String.Format(CultureInfo.CurrentCulture, Resources.PropertyTooShort, "Name"));
|
errors.Add(String.Format(CultureInfo.CurrentCulture, Resources.PropertyTooShort, "Name"));
|
||||||
}
|
}
|
||||||
else if (AllowOnlyAlphanumericUserNames && !Regex.IsMatch(user.UserName, @"^[A-Za-z0-9@_\.]+$"))
|
else if (AllowOnlyAlphanumericUserNames && !user.UserName.All(IsAlphaNumeric))
|
||||||
{
|
{
|
||||||
// If any characters are not letters or digits, its an illegal user name
|
// If any characters are not letters or digits, its an illegal user name
|
||||||
errors.Add(String.Format(CultureInfo.CurrentCulture, Resources.InvalidUserName, user.UserName));
|
errors.Add(String.Format(CultureInfo.CurrentCulture, Resources.InvalidUserName, user.UserName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var owner = await Manager.FindByName(user.UserName);
|
var owner = await manager.FindByName(user.UserName);
|
||||||
if (owner != null && !EqualityComparer<TKey>.Default.Equals(owner.Id, user.Id))
|
if (owner != null && !EqualityComparer<TKey>.Default.Equals(owner.Id, user.Id))
|
||||||
{
|
{
|
||||||
errors.Add(String.Format(CultureInfo.CurrentCulture, Resources.DuplicateName, user.UserName));
|
errors.Add(String.Format(CultureInfo.CurrentCulture, Resources.DuplicateName, user.UserName));
|
||||||
|
|
@ -90,9 +128,9 @@ namespace Microsoft.AspNet.Identity
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure email is not empty, valid, and unique
|
// make sure email is not empty, valid, and unique
|
||||||
private async Task ValidateEmail(TUser user, List<string> errors)
|
private async Task ValidateEmail(UserManager<TUser, TKey> manager, TUser user, List<string> errors)
|
||||||
{
|
{
|
||||||
var email = await Manager.GetEmailStore().GetEmail(user).ConfigureAwait(false);
|
var email = await manager.GetEmailStore().GetEmail(user).ConfigureAwait(false);
|
||||||
if (string.IsNullOrWhiteSpace(email))
|
if (string.IsNullOrWhiteSpace(email))
|
||||||
{
|
{
|
||||||
errors.Add(String.Format(CultureInfo.CurrentCulture, Resources.PropertyTooShort, "Email"));
|
errors.Add(String.Format(CultureInfo.CurrentCulture, Resources.PropertyTooShort, "Email"));
|
||||||
|
|
@ -109,7 +147,7 @@ namespace Microsoft.AspNet.Identity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
var owner = await Manager.FindByEmail(email);
|
var owner = await manager.FindByEmail(email);
|
||||||
if (owner != null && !EqualityComparer<TKey>.Default.Equals(owner.Id, user.Id))
|
if (owner != null && !EqualityComparer<TKey>.Default.Equals(owner.Id, user.Id))
|
||||||
{
|
{
|
||||||
errors.Add(String.Format(CultureInfo.CurrentCulture, Resources.DuplicateEmail, email));
|
errors.Add(String.Format(CultureInfo.CurrentCulture, Resources.DuplicateEmail, email));
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,33 @@
|
||||||
{
|
{
|
||||||
"version": "0.1-alpha-*",
|
"version" : "0.1-alpha-*",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*",
|
"Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*",
|
||||||
"System.Security.Claims" : "0.1-alpha-*",
|
"System.Security.Claims" : "0.1-alpha-*",
|
||||||
"Microsoft.AspNet.Security.DataProtection" : "0.1-alpha-*"
|
"Microsoft.AspNet.Security.DataProtection" : "0.1-alpha-*"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"net45": {},
|
"net45": {
|
||||||
|
"dependencies": {
|
||||||
|
"System.Runtime": "",
|
||||||
|
"System.Collections": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
"k10": {
|
"k10": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"System.Collections": "4.0.0.0",
|
"System.Collections": "4.0.0.0",
|
||||||
|
"System.Collections.Concurrent": "4.0.0.0",
|
||||||
"System.ComponentModel": "4.0.0.0",
|
"System.ComponentModel": "4.0.0.0",
|
||||||
|
"System.Console": "4.0.0.0",
|
||||||
"System.Diagnostics.Debug": "4.0.10.0",
|
"System.Diagnostics.Debug": "4.0.10.0",
|
||||||
"System.Diagnostics.Tools": "4.0.0.0",
|
|
||||||
"System.Globalization": "4.0.10.0",
|
"System.Globalization": "4.0.10.0",
|
||||||
"System.Linq": "4.0.0.0",
|
"System.Linq": "4.0.0.0",
|
||||||
"System.Linq.Expressions": "4.0.0.0",
|
"System.Linq.Expressions": "4.0.0.0",
|
||||||
"System.Reflection": "4.0.10.0",
|
"System.Reflection": "4.0.10.0",
|
||||||
|
"System.Reflection.Extensions": "4.0.0.0",
|
||||||
"System.Resources.ResourceManager": "4.0.0.0",
|
"System.Resources.ResourceManager": "4.0.0.0",
|
||||||
"System.Runtime": "4.0.20.0",
|
"System.Runtime": "4.0.20.0",
|
||||||
"System.Runtime.Extensions": "4.0.10.0",
|
"System.Runtime.Extensions": "4.0.10.0",
|
||||||
"System.Security.Principal": "4.0.0.0",
|
"System.Threading": "4.0.0.0",
|
||||||
"System.Text.Encoding": "4.0.10.0",
|
|
||||||
"System.Text.RegularExpressions": "4.0.0.0",
|
|
||||||
"System.Threading.Tasks": "4.0.0.0"
|
"System.Threading.Tasks": "4.0.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,40 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNet.Identity" : "0.1-alpha-*",
|
"Microsoft.AspNet.Identity" : "0.1-alpha-*",
|
||||||
"Microsoft.AspNet.Identity.InMemory" : "0.1-alpha-*",
|
"Microsoft.AspNet.Identity.InMemory" : "0.1-alpha-*",
|
||||||
"Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*"
|
"Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*",
|
||||||
|
"Xunit.KRunner": "0.1-alpha-*",
|
||||||
|
"xunit.abstractions": "3.0.0-alpha-*",
|
||||||
|
"xunit2": "0.1-alpha-*",
|
||||||
|
"xunit2.assert": "0.1-alpha-*"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"net45": {
|
"net45": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"xunit": "1.9.2"
|
"System.Runtime": "",
|
||||||
|
"System.Collections": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"k10": {
|
||||||
|
"dependencies": {
|
||||||
|
"System.Collections": "4.0.0.0",
|
||||||
|
"System.Collections.Concurrent": "4.0.0.0",
|
||||||
|
"System.ComponentModel": "4.0.0.0",
|
||||||
|
"System.Console": "4.0.0.0",
|
||||||
|
"System.Diagnostics.Debug": "4.0.10.0",
|
||||||
|
"System.Globalization": "4.0.10.0",
|
||||||
|
"System.Linq": "4.0.0.0",
|
||||||
|
"System.Linq.Expressions": "4.0.0.0",
|
||||||
|
"System.Reflection": "4.0.10.0",
|
||||||
|
"System.Reflection.Extensions": "4.0.0.0",
|
||||||
|
"System.Resources.ResourceManager": "4.0.0.0",
|
||||||
|
"System.Runtime": "4.0.20.0",
|
||||||
|
"System.Runtime.Extensions": "4.0.10.0",
|
||||||
|
"System.Threading": "4.0.0.0",
|
||||||
|
"System.Threading.Tasks": "4.0.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"commands": {
|
||||||
|
"test": "Xunit.KRunner"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.AspNet.DependencyInjection;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Identity.Test
|
||||||
|
{
|
||||||
|
public static class TestServices
|
||||||
|
{
|
||||||
|
public static IServiceProvider DefaultServiceProvider<TUser, TKey>()
|
||||||
|
where TUser : class,IUser<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return new ServiceProvider().Add(TestServices.DefaultServices<TUser, TKey>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<IServiceDescriptor> DefaultServices<TUser, TKey>()
|
||||||
|
where TUser : class,IUser<TKey>
|
||||||
|
where TKey : IEquatable<TKey>
|
||||||
|
{
|
||||||
|
return new IServiceDescriptor[]
|
||||||
|
{
|
||||||
|
new ServiceDescriptor<IPasswordValidator, PasswordValidator>(),
|
||||||
|
new ServiceDescriptor<IUserValidator<TUser, TKey>, UserValidator<TUser, TKey>>(),
|
||||||
|
new ServiceDescriptor<IPasswordHasher, PasswordHasher>(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ServiceDescriptor<TService, TImplementation> : IServiceDescriptor
|
||||||
|
{
|
||||||
|
public ServiceDescriptor(LifecycleKind lifecycle = LifecycleKind.Transient)
|
||||||
|
{
|
||||||
|
Lifecycle = lifecycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LifecycleKind Lifecycle { get; private set; }
|
||||||
|
|
||||||
|
public Type ServiceType
|
||||||
|
{
|
||||||
|
get { return typeof (TService); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type ImplementationType
|
||||||
|
{
|
||||||
|
get { return typeof (TImplementation); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ImplementationInstance
|
||||||
|
{
|
||||||
|
get { return null; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ServiceInstanceDescriptor<TService> : IServiceDescriptor
|
||||||
|
{
|
||||||
|
public ServiceInstanceDescriptor(object instance)
|
||||||
|
{
|
||||||
|
ImplementationInstance = instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LifecycleKind Lifecycle
|
||||||
|
{
|
||||||
|
get { return LifecycleKind.Singleton; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type ServiceType
|
||||||
|
{
|
||||||
|
get { return typeof (TService); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type ImplementationType
|
||||||
|
{
|
||||||
|
get { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ImplementationInstance { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,341 @@
|
||||||
|
using Moq;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Identity.Test
|
||||||
|
{
|
||||||
|
public class UserManagerTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void ServiceProviderWireupTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(TestServices.DefaultServiceProvider<TestUser, string>());
|
||||||
|
Assert.NotNull(manager.PasswordHasher);
|
||||||
|
Assert.NotNull(manager.PasswordValidator);
|
||||||
|
Assert.NotNull(manager.UserValidator);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Mock fails in K (this works fine in net45)
|
||||||
|
//[Fact]
|
||||||
|
//public async Task CreateTest()
|
||||||
|
//{
|
||||||
|
// // Setup
|
||||||
|
// var store = new Mock<IUserStore<TestUser, string>>();
|
||||||
|
// var user = new TestUser();
|
||||||
|
// store.Setup(s => s.Create(user)).Verifiable();
|
||||||
|
// var userManager = new UserManager<TestUser, string>(store.Object);
|
||||||
|
|
||||||
|
// // Act
|
||||||
|
// var result = await userManager.Create(user);
|
||||||
|
|
||||||
|
// // Assert
|
||||||
|
// Assert.True(result.Succeeded);
|
||||||
|
// store.VerifyAll();
|
||||||
|
//}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void UsersQueryableFailWhenStoreNotImplementedTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
Assert.False(manager.SupportsQueryableUsers);
|
||||||
|
Assert.Throws<NotSupportedException>(() => manager.Users.Count());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void UsersEmailMethodsFailWhenStoreNotImplementedTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
Assert.False(manager.SupportsUserEmail);
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.FindByEmail(null));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.SetEmail(null, null));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.GetEmail(null));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.IsEmailConfirmed(null));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.ConfirmEmail(null, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void UsersPhoneNumberMethodsFailWhenStoreNotImplementedTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
Assert.False(manager.SupportsUserPhoneNumber);
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.SetPhoneNumber(null, null)));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.SetPhoneNumber(null, null));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.GetPhoneNumber(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
//[Fact]
|
||||||
|
//public void TokenMethodsThrowWithNoTokenProviderTest()
|
||||||
|
//{
|
||||||
|
// var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
// Assert.Throws<NotSupportedException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GenerateUserTokenAsync(null, null)));
|
||||||
|
// Assert.Throws<NotSupportedException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.VerifyUserTokenAsync(null, null, null)));
|
||||||
|
//}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void PasswordMethodsFailWhenStoreNotImplementedTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
Assert.False(manager.SupportsUserPassword);
|
||||||
|
//Assert.Throws<NotSupportedException>(() => AsyncHelper.RunSync(() => manager.CreateAsync(null, null)));
|
||||||
|
//Assert.Throws<NotSupportedException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.ChangePasswordAsync(null, null, null)));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => AsyncHelper.RunSync(() => manager.AddPasswordAsync(null, null)));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => AsyncHelper.RunSync(() => manager.RemovePasswordAsync(null)));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => AsyncHelper.RunSync(() => manager.CheckPasswordAsync(null, null)));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => AsyncHelper.RunSync(() => manager.HasPasswordAsync(null)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void SecurityStampMethodsFailWhenStoreNotImplementedTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
Assert.False(manager.SupportsUserSecurityStamp);
|
||||||
|
//Assert.Throws<NotSupportedException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.UpdateSecurityStampAsync("bogus")));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => AsyncHelper.RunSync(() => manager.GetSecurityStampAsync("bogus")));
|
||||||
|
//Assert.Throws<NotSupportedException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.VerifyChangePhoneNumberTokenAsync("bogus", "1", "111-111-1111")));
|
||||||
|
//Assert.Throws<NotSupportedException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GenerateChangePhoneNumberTokenAsync("bogus", "111-111-1111")));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void LoginMethodsFailWhenStoreNotImplementedTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
Assert.False(manager.SupportsUserLogin);
|
||||||
|
//Assert.Throws<NotSupportedException>(() => AsyncHelper.RunSync(() => manager.AddLoginAsync("bogus", null)));
|
||||||
|
//Assert.Throws<NotSupportedException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.RemoveLoginAsync("bogus", null)));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => AsyncHelper.RunSync(() => manager.GetLoginsAsync("bogus")));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => AsyncHelper.RunSync(() => manager.FindAsync(null)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ClaimMethodsFailWhenStoreNotImplementedTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
Assert.False(manager.SupportsUserClaim);
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.AddClaim("bogus", null));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.RemoveClaim("bogus", null));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.GetClaims("bogus"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TwoFactorStoreMethodsFailWhenStoreNotImplementedTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
Assert.False(manager.SupportsUserTwoFactor);
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.GetTwoFactorEnabled("bogus"));
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.SetTwoFactorEnabled("bogus", true));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void RoleMethodsFailWhenStoreNotImplementedTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
Assert.False(manager.SupportsUserRole);
|
||||||
|
//Assert.Throws<NotSupportedException>(() => manager.AddToRole("bogus", null).Wait());
|
||||||
|
//Assert.Throws<NotSupportedException>(async () => await manager.GetRoles("bogus"));
|
||||||
|
//Assert.Throws<NotSupportedException>(async () => await manager.RemoveFromRole("bogus", null));
|
||||||
|
//Assert.Throws<NotSupportedException>(async () => await manager.IsInRole("bogus", "bogus"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void DisposeAfterDisposeWorksTest()
|
||||||
|
{
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
manager.Dispose();
|
||||||
|
manager.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ManagerPublicNullCheckTest()
|
||||||
|
{
|
||||||
|
Assert.Throws<ArgumentNullException>(() => new UserManager<TestUser, string>((IUserStore<TestUser, string>)null));
|
||||||
|
var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
Assert.Throws<ArgumentNullException>(() => manager.ClaimsIdentityFactory = null);
|
||||||
|
Assert.Throws<ArgumentNullException>(() => manager.PasswordHasher = null);
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.CreateIdentity(null, "whatever"));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.Create(null));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.Create(null, null));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.Create(new TestUser(), null));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.Update(null));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.Delete(null));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.AddClaim("bogus", null));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.FindByName(null));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.Find(null, null));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.AddLogin("bogus", null));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.RemoveLogin("bogus", null));
|
||||||
|
//Assert.Throws<ArgumentNullException>(() => manager.FindByEmail(null));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => manager.RegisterTwoFactorProvider(null, null));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => manager.RegisterTwoFactorProvider("bogus", null));
|
||||||
|
}
|
||||||
|
|
||||||
|
//[Fact]
|
||||||
|
//public void MethodsFailWithUnknownUserTest()
|
||||||
|
//{
|
||||||
|
// var db = UnitTestHelper.CreateDefaultDb();
|
||||||
|
// var manager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(db));
|
||||||
|
// manager.UserTokenProvider = new NoOpTokenProvider();
|
||||||
|
// var error = "UserId not found.";
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.AddClaimAsync(null, new Claim("a", "b"))), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.AddLoginAsync(null, new UserLoginInfo("", ""))), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.AddPasswordAsync(null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.AddToRoleAsync(null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.ChangePasswordAsync(null, null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GetClaimsAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GetLoginsAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GetRolesAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.IsInRoleAsync(null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.RemoveClaimAsync(null, new Claim("a", "b"))), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.RemoveLoginAsync(null, new UserLoginInfo("", ""))), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.RemovePasswordAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.RemoveFromRoleAsync(null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.UpdateSecurityStampAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GetSecurityStampAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.HasPasswordAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GeneratePasswordResetTokenAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.ResetPasswordAsync(null, null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.IsEmailConfirmedAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GenerateEmailConfirmationTokenAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.ConfirmEmailAsync(null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GetEmailAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.SetEmailAsync(null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.IsPhoneNumberConfirmedAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.ChangePhoneNumberAsync(null, null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.VerifyChangePhoneNumberTokenAsync(null, null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GetPhoneNumberAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.SetPhoneNumberAsync(null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GetTwoFactorEnabledAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.SetTwoFactorEnabledAsync(null, true)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GenerateTwoFactorTokenAsync(null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.VerifyTwoFactorTokenAsync(null, null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.NotifyTwoFactorTokenAsync(null, null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.GetValidTwoFactorProvidersAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.VerifyUserTokenAsync(null, null, null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.AccessFailedAsync(null)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.SetLockoutEnabledAsync(null, false)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.SetLockoutEndDateAsync(null, DateTimeOffset.UtcNow)), error);
|
||||||
|
// ExceptionHelper.ThrowsWithError<InvalidOperationException>(
|
||||||
|
// () => AsyncHelper.RunSync(() => manager.IsLockedOutAsync(null)), error);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//[Fact]
|
||||||
|
//public void MethodsThrowWhenDisposedTest()
|
||||||
|
//{
|
||||||
|
// var manager = new UserManager<TestUser, string>(new NoopUserStore());
|
||||||
|
// manager.Dispose();
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.AddClaim("bogus", null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.AddLogin("bogus", null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.AddPassword("bogus", null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.AddToRole("bogus", null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.ChangePassword("bogus", null, null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.GetClaims("bogus"));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.GetLogins("bogus"));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.GetRoles("bogus"));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.IsInRole("bogus", null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.RemoveClaim("bogus", null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.RemoveLogin("bogus", null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.RemovePassword("bogus"));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.RemoveFromRole("bogus", null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.RemoveClaim("bogus", null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.Find("bogus", null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.Find(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.FindById(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.FindByName(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.Create(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.Create(null, null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.CreateIdentity(null, null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.Update(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.Delete(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.UpdateSecurityStamp(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.GetSecurityStamp(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.GeneratePasswordResetToken(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.ResetPassword(null, null, null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.GenerateEmailConfirmationToken(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.IsEmailConfirmed(null));
|
||||||
|
// Assert.Throws<ObjectDisposedException>(() => manager.ConfirmEmail(null, null));
|
||||||
|
//}
|
||||||
|
|
||||||
|
private class TestUser : IUser<string>
|
||||||
|
{
|
||||||
|
public string Id { get; private set; }
|
||||||
|
public string UserName { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NoopUserStore : IUserStore<TestUser, string>
|
||||||
|
{
|
||||||
|
public Task Create(TestUser user)
|
||||||
|
{
|
||||||
|
return Task.FromResult(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Update(TestUser user)
|
||||||
|
{
|
||||||
|
return Task.FromResult(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TestUser> FindById(string userId)
|
||||||
|
{
|
||||||
|
return Task.FromResult<TestUser>(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<TestUser> FindByName(string userName)
|
||||||
|
{
|
||||||
|
return Task.FromResult<TestUser>(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Delete(TestUser user)
|
||||||
|
{
|
||||||
|
return Task.FromResult(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,13 +2,41 @@
|
||||||
"version": "0.1-alpha-*",
|
"version": "0.1-alpha-*",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNet.Identity" : "0.1-alpha-*",
|
"Microsoft.AspNet.Identity" : "0.1-alpha-*",
|
||||||
"Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*"
|
"Microsoft.AspNet.DependencyInjection" : "0.1-alpha-*",
|
||||||
|
"Xunit.KRunner": "0.1-alpha-*",
|
||||||
|
"xunit.abstractions": "3.0.0-alpha-*",
|
||||||
|
"xunit2": "0.1-alpha-*",
|
||||||
|
"xunit2.assert": "0.1-alpha-*"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"net45": {
|
"net45": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"xunit": "1.9.2"
|
"Moq" : "4.2.1312.1622",
|
||||||
|
"System.Runtime": "",
|
||||||
|
"System.Collections": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"k10": {
|
||||||
|
"dependencies": {
|
||||||
|
"System.Collections": "4.0.0.0",
|
||||||
|
"System.Collections.Concurrent": "4.0.0.0",
|
||||||
|
"System.ComponentModel": "4.0.0.0",
|
||||||
|
"System.Console": "4.0.0.0",
|
||||||
|
"System.Diagnostics.Debug": "4.0.10.0",
|
||||||
|
"System.Globalization": "4.0.10.0",
|
||||||
|
"System.Linq": "4.0.0.0",
|
||||||
|
"System.Linq.Expressions": "4.0.0.0",
|
||||||
|
"System.Reflection": "4.0.10.0",
|
||||||
|
"System.Reflection.Extensions": "4.0.0.0",
|
||||||
|
"System.Resources.ResourceManager": "4.0.0.0",
|
||||||
|
"System.Runtime": "4.0.20.0",
|
||||||
|
"System.Runtime.Extensions": "4.0.10.0",
|
||||||
|
"System.Threading": "4.0.0.0",
|
||||||
|
"System.Threading.Tasks": "4.0.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"commands": {
|
||||||
|
"test": "Xunit.KRunner"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue