Add Identity.Specfification.Tests

This commit is contained in:
Hao Kung 2016-12-12 13:55:08 -08:00
parent 34519a43f6
commit 5e4e9ccdf1
31 changed files with 754 additions and 46 deletions

View File

@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0F647068-6602-4E24-B1DC-8ED91481A50A}"
EndProject
@ -29,6 +29,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Identi
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Identity.AspNetCoreCompat", "src\Microsoft.AspNet.Identity.AspNetCoreCompat\Microsoft.AspNet.Identity.AspNetCoreCompat.xproj", "{6A74C6EA-B241-4D6B-BCE4-BF89EC1D2475}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Identity.Specification.Tests", "src\Microsoft.AspNetCore.Identity.Specification.Tests\Microsoft.AspNetCore.Identity.Specification.Tests.xproj", "{5608E828-DD54-4E2A-B73C-FC22268BE797}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -121,6 +123,18 @@ Global
{6A74C6EA-B241-4D6B-BCE4-BF89EC1D2475}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{6A74C6EA-B241-4D6B-BCE4-BF89EC1D2475}.Release|x86.ActiveCfg = Release|Any CPU
{6A74C6EA-B241-4D6B-BCE4-BF89EC1D2475}.Release|x86.Build.0 = Release|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Debug|x86.ActiveCfg = Debug|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Debug|x86.Build.0 = Debug|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Release|Any CPU.Build.0 = Release|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Release|x86.ActiveCfg = Release|Any CPU
{5608E828-DD54-4E2A-B73C-FC22268BE797}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -134,5 +148,6 @@ Global
{EA7EB28F-53B8-4009-9C6B-74DB090CA8DD} = {52D59F18-62D2-4D17-8CF2-BE192445AF8E}
{4490894C-3572-4E63-86F1-EE5105CE8A06} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
{6A74C6EA-B241-4D6B-BCE4-BF89EC1D2475} = {0F647068-6602-4E24-B1DC-8ED91481A50A}
{5608E828-DD54-4E2A-B73C-FC22268BE797} = {52D59F18-62D2-4D17-8CF2-BE192445AF8E}
EndGlobalSection
EndGlobal

View File

@ -220,7 +220,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// <param name="role">The role whose ID should be returned.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>A <see cref="Task{TResult}"/> that contains the ID of the role.</returns>
public Task<string> GetRoleIdAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
public virtual Task<string> GetRoleIdAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
@ -237,7 +237,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// <param name="role">The role whose name should be returned.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>A <see cref="Task{TResult}"/> that contains the name of the role.</returns>
public Task<string> GetRoleNameAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
public virtual Task<string> GetRoleNameAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
@ -255,7 +255,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// <param name="roleName">The name of the role.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public Task SetRoleNameAsync(TRole role, string roleName, CancellationToken cancellationToken = default(CancellationToken))
public virtual Task SetRoleNameAsync(TRole role, string roleName, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
@ -383,7 +383,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// <param name="role">The role whose claims should be retrieved.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>A <see cref="Task{TResult}"/> that contains the claims granted to a role.</returns>
public async Task<IList<Claim>> GetClaimsAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
public async virtual Task<IList<Claim>> GetClaimsAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken))
{
ThrowIfDisposed();
if (role == null)
@ -401,7 +401,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// <param name="claim">The claim to add to the role.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public Task AddClaimAsync(TRole role, Claim claim, CancellationToken cancellationToken = default(CancellationToken))
public virtual Task AddClaimAsync(TRole role, Claim claim, CancellationToken cancellationToken = default(CancellationToken))
{
ThrowIfDisposed();
if (role == null)
@ -424,7 +424,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// <param name="claim">The claim to remove from the role.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public async Task RemoveClaimAsync(TRole role, Claim claim, CancellationToken cancellationToken = default(CancellationToken))
public async virtual Task RemoveClaimAsync(TRole role, Claim claim, CancellationToken cancellationToken = default(CancellationToken))
{
ThrowIfDisposed();
if (role == null)

View File

@ -1411,7 +1411,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// <param name="name">The name of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public async Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
public async virtual Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
@ -1435,7 +1435,7 @@ namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore
/// <param name="name">The name of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public async Task<string> GetTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
public async virtual Task<string> GetTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();

View File

@ -1,27 +1,39 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics;
using System.Linq;
using Microsoft.Extensions.Logging;
using Xunit;
namespace Microsoft.AspNetCore.Identity.Test
{
/// <summary>
/// Helper for tests to validate identity results.
/// </summary>
public static class IdentityResultAssert
{
/// <summary>
/// Asserts that the result has Succeeded.
/// </summary>
/// <param name="result"></param>
public static void IsSuccess(IdentityResult result)
{
Assert.NotNull(result);
Assert.True(result.Succeeded);
}
/// <summary>
/// Asserts that the result has not Succeeded.
/// </summary>
public static void IsFailure(IdentityResult result)
{
Assert.NotNull(result);
Assert.False(result.Succeeded);
}
/// <summary>
/// Asserts that the result has not Succeeded and that error is the first Error's Description.
/// </summary>
public static void IsFailure(IdentityResult result, string error)
{
Assert.NotNull(result);
@ -29,6 +41,9 @@ namespace Microsoft.AspNetCore.Identity.Test
Assert.Equal(error, result.Errors.First().Description);
}
/// <summary>
/// Asserts that the result has not Succeeded and that first error matches error's code and Description.
/// </summary>
public static void IsFailure(IdentityResult result, IdentityError error)
{
Assert.NotNull(result);
@ -37,6 +52,11 @@ namespace Microsoft.AspNetCore.Identity.Test
Assert.Equal(error.Code, result.Errors.First().Code);
}
/// <summary>
/// Asserts that the logger contains the expectedLog.
/// </summary>
/// <param name="logger">The logger to inspect.</param>
/// <param name="expectedLog">The expected log message.</param>
public static void VerifyLogMessage(ILogger logger, string expectedLog)
{
var testlogger = logger as ITestLogger;

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>5608e828-dd54-4e2a-b73c-fc22268be797</ProjectGuid>
<RootNamespace>Microsoft.AspNetCore.Identity.Specification.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@ -0,0 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
[assembly: AssemblyMetadata("Serviceable", "True")]
[assembly: NeutralResourcesLanguage("en-us")]
[assembly: AssemblyCompany("Microsoft Corporation.")]
[assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyProduct("Microsoft ASP.NET Core")]

View File

@ -7,26 +7,58 @@ using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Identity.Test
{
/// <summary>
/// test logger.
/// </summary>
public interface ITestLogger
{
/// <summary>
/// log messages.
/// </summary>
IList<string> LogMessages { get; }
}
/// <summary>
/// Test logger.
/// </summary>
/// <typeparam name="TName"></typeparam>
public class TestLogger<TName> : ILogger<TName>, ITestLogger
{
/// <summary>
/// log messages.
/// </summary>
public IList<string> LogMessages { get; } = new List<string>();
/// <summary>
/// </summary>
/// <typeparam name="TState"></typeparam>
/// <param name="state"></param>
/// <returns></returns>
public IDisposable BeginScope<TState>(TState state)
{
LogMessages.Add(state?.ToString());
return null;
}
/// <summary>
///
/// </summary>
/// <param name="logLevel"></param>
/// <returns></returns>
public bool IsEnabled(LogLevel logLevel)
{
return true;
}
/// <summary>
///
/// </summary>
/// <typeparam name="TState"></typeparam>
/// <param name="logLevel"></param>
/// <param name="eventId"></param>
/// <param name="state"></param>
/// <param name="exception"></param>
/// <param name="formatter"></param>
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
if (formatter == null)

View File

@ -0,0 +1,42 @@
{
"description": "Shared test suite for Asp.Net Identity Core store implementations.",
"version": "1.2.0-*",
"buildOptions": {
"warningsAsErrors": true,
"keyFile": "../../tools/Key.snk",
"xmlDoc": true
},
"packOptions": {
"repository": {
"type": "git",
"url": "git://github.com/aspnet/identity"
},
"tags": [
"aspnetcore",
"identity",
"membership"
]
},
"dependencies": {
"Microsoft.AspNetCore.Identity": {
"target": "project"
},
"Microsoft.AspNetCore.Testing": "1.2.0-*",
"Microsoft.Extensions.DependencyInjection": "1.2.0-*",
"Microsoft.Extensions.Logging": "1.2.0-*",
"Microsoft.Extensions.TaskCache.Sources": {
"version": "1.2.0-*",
"type": "build"
},
"NETStandard.Library": "1.6.1-*",
"xunit": "2.2.0-*"
},
"frameworks": {
"net451": {},
"netstandard1.3": {
"dependencies": {
"System.Linq.Queryable": "4.3.0-*"
}
}
}
}

View File

@ -1,10 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Identity.Specification.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Identity.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Identity.EntityFrameworkCore.InMemory.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

View File

@ -9,7 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.InMemory.Test
{
public class InMemoryEFUserStoreTest : UserManagerTestBase<IdentityUser, IdentityRole, string>
public class InMemoryEFUserStoreTest : IdentitySpecificationTestBase<IdentityUser, IdentityRole, string>
{
protected override object CreateTestContext()
{

View File

@ -15,7 +15,7 @@ using Xunit;
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.InMemory.Test
{
public class InMemoryEFUserStoreTestWithGenerics : UserManagerTestBase<IdentityUserWithGenerics, MyIdentityRole, string>, IDisposable
public class InMemoryEFUserStoreTestWithGenerics : IdentitySpecificationTestBase<IdentityUserWithGenerics, MyIdentityRole, string>, IDisposable
{
private readonly InMemoryContextWithGenerics _context;
private UserStoreWithGenerics _store;

View File

@ -12,6 +12,7 @@
"Microsoft.AspNetCore.Http": "1.2.0-*",
"Microsoft.AspNetCore.Identity": "1.2.0-*",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.2.0-*",
"Microsoft.AspNetCore.Identity.Specification.Tests": "1.2.0-*",
"Microsoft.AspNetCore.Testing": "1.2.0-*",
"Microsoft.EntityFrameworkCore.InMemory": "1.2.0-*",
"Moq": "4.6.36-*",

View File

@ -0,0 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Reflection;
using Microsoft.AspNetCore.Identity.Test;
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
{
public class ApiConsistencyTest : ApiConsistencyTestBase
{
protected override Assembly TargetAssembly => typeof(IdentityUser).GetTypeInfo().Assembly;
}
}

View File

@ -16,7 +16,7 @@ using Xunit;
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
{
public abstract class SqlStoreTestBase<TUser, TRole, TKey> : UserManagerTestBase<TUser, TRole, TKey>, IClassFixture<ScratchDatabaseFixture>
public abstract class SqlStoreTestBase<TUser, TRole, TKey> : IdentitySpecificationTestBase<TUser, TRole, TKey>, IClassFixture<ScratchDatabaseFixture>
where TUser : IdentityUser<TKey>, new()
where TRole : IdentityRole<TKey>, new()
where TKey : IEquatable<TKey>

View File

@ -14,7 +14,7 @@ using Xunit;
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
{
public class UserStoreTest : UserManagerTestBase<IdentityUser, IdentityRole>, IClassFixture<ScratchDatabaseFixture>
public class UserStoreTest : IdentitySpecificationTestBase<IdentityUser, IdentityRole>, IClassFixture<ScratchDatabaseFixture>
{
private readonly ScratchDatabaseFixture _fixture;

View File

@ -15,7 +15,7 @@ using Xunit;
namespace Microsoft.AspNetCore.Identity.EntityFrameworkCore.Test
{
public class UserStoreWithGenericsTest : UserManagerTestBase<IdentityUserWithGenerics, MyIdentityRole, string>, IClassFixture<ScratchDatabaseFixture>
public class UserStoreWithGenericsTest : IdentitySpecificationTestBase<IdentityUserWithGenerics, MyIdentityRole, string>, IClassFixture<ScratchDatabaseFixture>
{
private readonly ScratchDatabaseFixture _fixture;

View File

@ -20,6 +20,7 @@
"Microsoft.AspNetCore.Http": "1.2.0-*",
"Microsoft.AspNetCore.Identity": "1.2.0-*",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.2.0-*",
"Microsoft.AspNetCore.Identity.Specification.Tests": "1.2.0-*",
"Microsoft.AspNetCore.TestHost": "1.2.0-*",
"Microsoft.AspNetCore.Testing": "1.2.0-*",
"Microsoft.EntityFrameworkCore.InMemory": "1.2.0-*",

View File

@ -8,7 +8,7 @@ using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Identity.InMemory.Test
{
public class InMemoryStoreTest : UserManagerTestBase<TestUser, TestRole>
public class InMemoryStoreTest : IdentitySpecificationTestBase<TestUser, TestRole>
{
protected override object CreateTestContext()
{

View File

@ -13,6 +13,7 @@
"Microsoft.AspNetCore.Hosting": "1.2.0-*",
"Microsoft.AspNetCore.Http": "1.2.0-*",
"Microsoft.AspNetCore.Identity": "1.2.0-*",
"Microsoft.AspNetCore.Identity.Specification.Tests": "1.2.0-*",
"Microsoft.AspNetCore.TestHost": "1.2.0-*",
"Microsoft.AspNetCore.Testing": "1.2.0-*",
"Moq": "4.6.36-*",

View File

@ -188,5 +188,11 @@ namespace Microsoft.AspNetCore.Identity.Test
}
}
}
private class PasswordHasherOptionsAccessor : IOptions<PasswordHasherOptions>
{
public PasswordHasherOptions Value { get; } = new PasswordHasherOptions();
}
}
}

View File

@ -11,6 +11,7 @@
"Microsoft.AspNetCore.Hosting": "1.2.0-*",
"Microsoft.AspNetCore.Http": "1.2.0-*",
"Microsoft.AspNetCore.Identity": "1.2.0-*",
"Microsoft.AspNetCore.Identity.Specification.Tests": "1.2.0-*",
"Microsoft.AspNetCore.Testing": "1.2.0-*",
"Microsoft.Extensions.Configuration": "1.2.0-*",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.2.0-*",

View File

@ -1,13 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Identity.Test
{
internal class PasswordHasherOptionsAccessor : IOptions<PasswordHasherOptions>
{
public PasswordHasherOptions Value { get; } = new PasswordHasherOptions();
}
}

View File

@ -9,19 +9,38 @@ namespace Microsoft.AspNetCore.Identity.Test
using Xunit.Abstractions;
using Xunit.Sdk;
/// <summary>
/// Test priority
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class TestPriorityAttribute : Attribute
{
/// <summary>
/// ctor
/// </summary>
/// <param name="priority"></param>
public TestPriorityAttribute(int priority)
{
Priority = priority;
}
/// <summary>
/// Priority
/// </summary>
public int Priority { get; private set; }
}
/// <summary>
/// Used to run tests in order.
/// </summary>
public class PriorityOrderer : ITestCaseOrderer
{
/// <summary>
/// Orders tests cases
/// </summary>
/// <typeparam name="XunitTestCase"></typeparam>
/// <param name="testCases"></param>
/// <returns></returns>
public IEnumerable<XunitTestCase> OrderTestCases<XunitTestCase>(IEnumerable<XunitTestCase> testCases) where XunitTestCase : ITestCase
{
var sortedMethods = new SortedDictionary<int, List<XunitTestCase>>();

View File

@ -35,6 +35,9 @@ namespace Microsoft.AspNetCore.Identity.Test
/// <typeparam name="TKey"></typeparam>
public class TestRole<TKey> where TKey : IEquatable<TKey>
{
/// <summary>
/// Constructor
/// </summary>
public TestRole() { }
/// <summary>
@ -60,6 +63,10 @@ namespace Microsoft.AspNetCore.Identity.Test
/// Role name
/// </summary>
public virtual string Name { get; set; }
/// <summary>
/// Normalized name used for equality
/// </summary>
public virtual string NormalizedName { get; set; }
/// <summary>

View File

@ -5,6 +5,9 @@ using System;
namespace Microsoft.AspNetCore.Identity.Test
{
/// <summary>
/// EntityType that represents one specific role claim
/// </summary>
public class TestRoleClaim : TestRoleClaim<string> { }
/// <summary>

View File

@ -6,30 +6,62 @@ using System.Collections.Generic;
namespace Microsoft.AspNetCore.Identity.Test
{
/// <summary>
/// Test user class
/// </summary>
public class TestUser : TestUser<string>
{
/// <summary>
/// Ctor
/// </summary>
public TestUser()
{
Id = Guid.NewGuid().ToString();
}
/// <summary>
/// Ctor
/// </summary>
/// <param name="userName"></param>
public TestUser(string userName) : this()
{
UserName = userName;
}
}
/// <summary>
/// Test user
/// </summary>
/// <typeparam name="TKey"></typeparam>
public class TestUser<TKey> where TKey : IEquatable<TKey>
{
/// <summary>
/// ctor
/// </summary>
public TestUser() { }
/// <summary>
/// ctor
/// </summary>
/// <param name="userName"></param>
public TestUser(string userName) : this()
{
UserName = userName;
}
/// <summary>
/// Id
/// </summary>
public virtual TKey Id { get; set; }
/// <summary>
/// Name
/// </summary>
public virtual string UserName { get; set; }
/// <summary>
/// normalized user name
/// </summary>
public virtual string NormalizedUserName { get; set; }
/// <summary>
@ -37,6 +69,9 @@ namespace Microsoft.AspNetCore.Identity.Test
/// </summary>
public virtual string Email { get; set; }
/// <summary>
/// normalized email
/// </summary>
public virtual string NormalizedEmail { get; set; }
/// <summary>
@ -89,9 +124,21 @@ namespace Microsoft.AspNetCore.Identity.Test
/// </summary>
public virtual int AccessFailedCount { get; set; }
/// <summary>
/// Navigation property
/// </summary>
public virtual ICollection<TestUserRole<TKey>> Roles { get; private set; } = new List<TestUserRole<TKey>>();
/// <summary>
/// Navigation property
/// </summary>
public virtual ICollection<TestUserClaim<TKey>> Claims { get; private set; } = new List<TestUserClaim<TKey>>();
/// <summary>
/// Navigation property
/// </summary>
public virtual ICollection<TestUserLogin<TKey>> Logins { get; private set; } = new List<TestUserLogin<TKey>>();
/// <summary>
/// Navigation property
/// </summary>
public virtual ICollection<TestUserToken<TKey>> Tokens { get; private set; } = new List<TestUserToken<TKey>>();
}
}

View File

@ -5,6 +5,9 @@ using System;
namespace Microsoft.AspNetCore.Identity.Test
{
/// <summary>
/// EntityType that represents one specific user claim
/// </summary>
public class TestUserClaim : TestUserClaim<string> { }
/// <summary>

View File

@ -5,6 +5,9 @@ using System;
namespace Microsoft.AspNetCore.Identity.Test
{
/// <summary>
/// Entity type for a user's login (i.e. facebook, google)
/// </summary>
public class TestUserLogin : TestUserLogin<string> { }
/// <summary>

View File

@ -5,6 +5,9 @@ using System;
namespace Microsoft.AspNetCore.Identity.Test
{
/// <summary>
/// EntityType that represents a user belonging to a role
/// </summary>
public class TestUserRole : TestUserRole<string> { }
/// <summary>

View File

@ -5,10 +5,13 @@ using System;
namespace Microsoft.AspNetCore.Identity.Test
{
/// <summary>
/// Entity type for a user's token
/// </summary>
public class TestUserToken : TestUserToken<string> { }
/// <summary>
/// Entity type for a user's login (i.e. facebook, google)
/// Entity type for a user's token
/// </summary>
/// <typeparam name="TKey"></typeparam>
public class TestUserToken<TKey> where TKey : IEquatable<TKey>