-
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 tests for IdentityServer model and queries
Fixes #20547
- Loading branch information
1 parent
03c1ba5
commit 9774a82
Showing
15 changed files
with
1,516 additions
and
176 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
test/EFCore.AspNet.InMemory.FunctionalTests/ConfigurationDbContextInMemoryTest.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 IdentityServer4.EntityFramework.DbContexts; | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore | ||
{ | ||
public class ConfigurationDbContextInMemoryTest | ||
: ConfigurationDbContextTestBase<ConfigurationDbContextInMemoryTest.ConfigurationDbContextInMemoryFixture> | ||
{ | ||
public ConfigurationDbContextInMemoryTest(ConfigurationDbContextInMemoryFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) | ||
{ | ||
} | ||
|
||
protected override async Task ExecuteWithStrategyInTransactionAsync( | ||
Func<ConfigurationDbContext, Task> testOperation, | ||
Func<ConfigurationDbContext, Task> nestedTestOperation1 = null, | ||
Func<ConfigurationDbContext, Task> nestedTestOperation2 = null, | ||
Func<ConfigurationDbContext, Task> nestedTestOperation3 = null) | ||
{ | ||
await base.ExecuteWithStrategyInTransactionAsync( | ||
testOperation, nestedTestOperation1, nestedTestOperation2, nestedTestOperation3); | ||
await Fixture.ReseedAsync(); | ||
} | ||
|
||
public class ConfigurationDbContextInMemoryFixture : ConfigurationDbContextFixtureBase | ||
{ | ||
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 | ||
=> "ConfigurationDbContext"; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
test/EFCore.AspNet.InMemory.FunctionalTests/PersistedGrantDbContextInMemoryTest.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 IdentityServer4.EntityFramework.DbContexts; | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore | ||
{ | ||
public class PersistedGrantDbContextInMemoryTest | ||
: PersistedGrantDbContextTestBase<PersistedGrantDbContextInMemoryTest.PersistedGrantDbContextInMemoryFixture> | ||
{ | ||
public PersistedGrantDbContextInMemoryTest(PersistedGrantDbContextInMemoryFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) | ||
{ | ||
} | ||
|
||
protected override async Task ExecuteWithStrategyInTransactionAsync( | ||
Func<PersistedGrantDbContext, Task> testOperation, | ||
Func<PersistedGrantDbContext, Task> nestedTestOperation1 = null, | ||
Func<PersistedGrantDbContext, Task> nestedTestOperation2 = null, | ||
Func<PersistedGrantDbContext, Task> nestedTestOperation3 = null) | ||
{ | ||
await base.ExecuteWithStrategyInTransactionAsync( | ||
testOperation, nestedTestOperation1, nestedTestOperation2, nestedTestOperation3); | ||
await Fixture.ReseedAsync(); | ||
} | ||
|
||
public class PersistedGrantDbContextInMemoryFixture : PersistedGrantDbContextFixtureBase | ||
{ | ||
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 | ||
=> "PersistedGrantDbContext"; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.