-
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.
- Loading branch information
Showing
10 changed files
with
166 additions
and
33 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
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
test/EFCore.Relational.Specification.Tests/DesignTimeTestBase.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,68 @@ | ||
// 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.Reflection; | ||
using Microsoft.EntityFrameworkCore.Design; | ||
using Microsoft.EntityFrameworkCore.Migrations.Design; | ||
using Microsoft.EntityFrameworkCore.Scaffolding; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Xunit; | ||
|
||
namespace Microsoft.EntityFrameworkCore | ||
{ | ||
public abstract class DesignTimeTestBase<TFixture> : IClassFixture<TFixture> | ||
where TFixture : DesignTimeTestBase<TFixture>.DesignTimeFixtureBase | ||
{ | ||
protected TFixture Fixture { get; } | ||
|
||
protected DesignTimeTestBase(TFixture fixture) | ||
=> Fixture = fixture; | ||
|
||
protected abstract Assembly ProviderAssembly { get; } | ||
|
||
[ConditionalFact] | ||
public void Can_get_reverse_engineering_services() | ||
{ | ||
using var context = Fixture.CreateContext(); | ||
var serviceCollection = new ServiceCollection() | ||
.AddEntityFrameworkDesignTimeServices(); | ||
((IDesignTimeServices)Activator.CreateInstance( | ||
ProviderAssembly.GetType( | ||
ProviderAssembly.GetCustomAttribute<DesignTimeProviderServicesAttribute>().TypeName, | ||
throwOnError: true))!) | ||
.ConfigureDesignTimeServices(serviceCollection); | ||
using var services = serviceCollection.BuildServiceProvider(); | ||
|
||
var reverseEngineerScaffolder = services.GetService<IReverseEngineerScaffolder>(); | ||
|
||
Assert.NotNull(reverseEngineerScaffolder); | ||
} | ||
|
||
[ConditionalFact] | ||
public void Can_get_migrations_services() | ||
{ | ||
using var context = Fixture.CreateContext(); | ||
var serviceCollection = new ServiceCollection() | ||
.AddEntityFrameworkDesignTimeServices() | ||
.AddDbContextDesignTimeServices(context); | ||
((IDesignTimeServices)Activator.CreateInstance( | ||
ProviderAssembly.GetType( | ||
ProviderAssembly.GetCustomAttribute<DesignTimeProviderServicesAttribute>().TypeName, | ||
throwOnError: true))!) | ||
.ConfigureDesignTimeServices(serviceCollection); | ||
using var services = serviceCollection.BuildServiceProvider(); | ||
|
||
var migrationsScaffolder = services.GetService<IMigrationsScaffolder>(); | ||
|
||
Assert.NotNull(migrationsScaffolder); | ||
} | ||
|
||
public abstract class DesignTimeFixtureBase : SharedStoreFixtureBase<PoolableDbContext> | ||
{ | ||
protected override string StoreName | ||
=> "DesignTimeTest"; | ||
} | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
test/EFCore.SqlServer.FunctionalTests/DesignTimeSqlServerTest.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,26 @@ | ||
// 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.EntityFrameworkCore.SqlServer.Design.Internal; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore | ||
{ | ||
public class DesignTimeSqlServerTest : DesignTimeTestBase<DesignTimeSqlServerTest.DesignTimeSqlServerFixture> | ||
{ | ||
public DesignTimeSqlServerTest(DesignTimeSqlServerFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected override Assembly ProviderAssembly | ||
=> typeof(SqlServerDesignTimeServices).Assembly; | ||
|
||
public class DesignTimeSqlServerFixture : DesignTimeFixtureBase | ||
{ | ||
protected override ITestStoreFactory TestStoreFactory | ||
=> SqlServerTestStoreFactory.Instance; | ||
} | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
test/EFCore.Sqlite.FunctionalTests/DesignTimeSqliteTest.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,26 @@ | ||
// 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.EntityFrameworkCore.Sqlite.Design.Internal; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore | ||
{ | ||
public class DesignTimeSqliteTest : DesignTimeTestBase<DesignTimeSqliteTest.DesignTimeSqliteFixture> | ||
{ | ||
public DesignTimeSqliteTest(DesignTimeSqliteFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected override Assembly ProviderAssembly | ||
=> typeof(SqliteDesignTimeServices).Assembly; | ||
|
||
public class DesignTimeSqliteFixture : DesignTimeFixtureBase | ||
{ | ||
protected override ITestStoreFactory TestStoreFactory | ||
=> SqliteTestStoreFactory.Instance; | ||
} | ||
} | ||
} |