-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add testing for ASP.NET Core Identity model
Fixes #11838 The intention here is not to test ASP.NET Core Identity. It is instead to test that: * The Identity model continues to build correctly with new versions of EF Core and across multipler providers, including external providers once they adopt these tests * The queries issues by Identity continue to work in new versions and across providers * The common (documented) customizations of the Identity model continue to work
- Loading branch information
1 parent
1ccf054
commit 1ebb947
Showing
23 changed files
with
2,192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityCustomTypesDefaultInMemoryTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// 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 System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Microsoft.EntityFrameworkCore | ||
{ | ||
public class AspNetIdentityCustomTypesDefaultInMemoryTest | ||
: AspNetIdentityCustomTypesDefaultTestBase< | ||
AspNetIdentityCustomTypesDefaultInMemoryTest.AspNetIdentityCustomTypesDefaultInMemoryFixture> | ||
{ | ||
public AspNetIdentityCustomTypesDefaultInMemoryTest(AspNetIdentityCustomTypesDefaultInMemoryFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) | ||
{ | ||
} | ||
|
||
protected override async Task ExecuteWithStrategyInTransactionAsync( | ||
Func<CustomTypesIdentityContext, Task> testOperation, | ||
Func<CustomTypesIdentityContext, Task> nestedTestOperation1 = null, | ||
Func<CustomTypesIdentityContext, Task> nestedTestOperation2 = null, | ||
Func<CustomTypesIdentityContext, Task> nestedTestOperation3 = null) | ||
{ | ||
await base.ExecuteWithStrategyInTransactionAsync( | ||
testOperation, nestedTestOperation1, nestedTestOperation2, nestedTestOperation3); | ||
await Fixture.ReseedAsync(); | ||
} | ||
|
||
public class AspNetIdentityCustomTypesDefaultInMemoryFixture : AspNetIdentityFixtureBase | ||
{ | ||
protected override IServiceCollection AddServices(IServiceCollection serviceCollection) | ||
=> base.AddServices(serviceCollection).AddEntityFrameworkProxies(); | ||
|
||
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
=> base.AddOptions(builder) | ||
.UseLazyLoadingProxies() | ||
.ConfigureWarnings(e => e.Ignore(InMemoryEventId.TransactionIgnoredWarning)); | ||
|
||
protected override ITestStoreFactory TestStoreFactory | ||
=> InMemoryTestStoreFactory.Instance; | ||
|
||
protected override string StoreName | ||
=> "AspNetCustomTypesDefaultIdentity"; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityCustomTypesIntKeyInMemoryTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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 System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore | ||
{ | ||
public class AspNetIdentityCustomTypesIntKeyInMemoryTest | ||
: AspNetIdentityCustomTypesIntKeyTestBase<AspNetIdentityCustomTypesIntKeyInMemoryTest.AspNetIdentityCustomTypesIntKeyInMemoryFixture | ||
> | ||
{ | ||
public AspNetIdentityCustomTypesIntKeyInMemoryTest(AspNetIdentityCustomTypesIntKeyInMemoryFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) | ||
{ | ||
} | ||
|
||
protected override async Task ExecuteWithStrategyInTransactionAsync( | ||
Func<CustomTypesIdentityContextInt, Task> testOperation, | ||
Func<CustomTypesIdentityContextInt, Task> nestedTestOperation1 = null, | ||
Func<CustomTypesIdentityContextInt, Task> nestedTestOperation2 = null, | ||
Func<CustomTypesIdentityContextInt, Task> nestedTestOperation3 = null) | ||
{ | ||
await base.ExecuteWithStrategyInTransactionAsync( | ||
testOperation, nestedTestOperation1, nestedTestOperation2, nestedTestOperation3); | ||
await Fixture.ReseedAsync(); | ||
} | ||
|
||
public class AspNetIdentityCustomTypesIntKeyInMemoryFixture : AspNetIdentityFixtureBase | ||
{ | ||
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
=> base.AddOptions(builder).ConfigureWarnings(e => e.Ignore(InMemoryEventId.TransactionIgnoredWarning)); | ||
|
||
protected override ITestStoreFactory TestStoreFactory | ||
=> InMemoryTestStoreFactory.Instance; | ||
|
||
protected override string StoreName | ||
=> "AspNetCustomTypesIntKeyIdentity"; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityDefaultInMemoryTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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 System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore | ||
{ | ||
public class AspNetIdentityDefaultInMemoryTest | ||
: AspNetIdentityDefaultTestBase<AspNetIdentityDefaultInMemoryTest.AspNetDefaultIdentityInMemoryFixture> | ||
{ | ||
public AspNetIdentityDefaultInMemoryTest(AspNetDefaultIdentityInMemoryFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) | ||
{ | ||
} | ||
|
||
protected override async Task ExecuteWithStrategyInTransactionAsync( | ||
Func<IdentityDbContext, Task> testOperation, | ||
Func<IdentityDbContext, Task> nestedTestOperation1 = null, | ||
Func<IdentityDbContext, Task> nestedTestOperation2 = null, | ||
Func<IdentityDbContext, Task> nestedTestOperation3 = null) | ||
{ | ||
await base.ExecuteWithStrategyInTransactionAsync( | ||
testOperation, nestedTestOperation1, nestedTestOperation2, nestedTestOperation3); | ||
await Fixture.ReseedAsync(); | ||
} | ||
|
||
public class AspNetDefaultIdentityInMemoryFixture : AspNetIdentityFixtureBase | ||
{ | ||
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
=> base.AddOptions(builder).ConfigureWarnings(e => e.Ignore(InMemoryEventId.TransactionIgnoredWarning)); | ||
|
||
protected override ITestStoreFactory TestStoreFactory | ||
=> InMemoryTestStoreFactory.Instance; | ||
|
||
protected override string StoreName | ||
=> "AspNetDefaultIdentity"; | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityIntKeyInMemoryTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// 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 System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore | ||
{ | ||
public class AspNetIdentityIntKeyInMemoryTest | ||
: AspNetIdentityIntKeyTestBase<AspNetIdentityIntKeyInMemoryTest.AspNetIdentityIntKeyInMemoryFixture> | ||
{ | ||
public AspNetIdentityIntKeyInMemoryTest(AspNetIdentityIntKeyInMemoryFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) | ||
{ | ||
} | ||
|
||
protected override async Task ExecuteWithStrategyInTransactionAsync( | ||
Func<IdentityDbContext<IdentityUser<int>, IdentityRole<int>, int>, Task> testOperation, | ||
Func<IdentityDbContext<IdentityUser<int>, IdentityRole<int>, int>, Task> nestedTestOperation1 = null, | ||
Func<IdentityDbContext<IdentityUser<int>, IdentityRole<int>, int>, Task> nestedTestOperation2 = null, | ||
Func<IdentityDbContext<IdentityUser<int>, IdentityRole<int>, int>, Task> nestedTestOperation3 = null) | ||
{ | ||
await base.ExecuteWithStrategyInTransactionAsync( | ||
testOperation, nestedTestOperation1, nestedTestOperation2, nestedTestOperation3); | ||
await Fixture.ReseedAsync(); | ||
} | ||
|
||
public class AspNetIdentityIntKeyInMemoryFixture : AspNetIdentityFixtureBase | ||
{ | ||
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
=> base.AddOptions(builder).ConfigureWarnings(e => e.Ignore(InMemoryEventId.TransactionIgnoredWarning)); | ||
|
||
protected override ITestStoreFactory TestStoreFactory | ||
=> InMemoryTestStoreFactory.Instance; | ||
|
||
protected override string StoreName | ||
=> "AspNetIntKeyIdentity"; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
test/EFCore.AspNet.InMemory.FunctionalTests/EFCore.AspNet.InMemory.FunctionalTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<AssemblyName>Microsoft.EntityFrameworkCore.AspNet.InMemory.FunctionalTests</AssemblyName> | ||
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace> | ||
<SkipTests Condition="'$(OS)' != 'Windows_NT' AND '$(Test__SqlServer__DefaultConnection)' == ''">True</SkipTests> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Update="config.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Include="..\xunit.runner.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EFCore.InMemory.FunctionalTests\EFCore.InMemory.FunctionalTests.csproj" /> | ||
<ProjectReference Include="..\EFCore.AspNet.Specification.Tests\EFCore.AspNet.Specification.Tests.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.