* Replace obsolete UserGroup Alias consts to key equivalent in tests * Update use of usergroup alias consts to key equivalent in IsSystemgroup extension method * Obsolete (internally) unused helper function which purpose doesn't even seem true * Prepped EmbedProviders for proper removal of non async methods and unneeded proxy methods * Remove obsoleted UmbracoPath and updated internal references * Corrected mistake and updated unittets * Update usergroup tests that use aliases for "system" groups * Replace more uses of globalsettings.UmbracoPath * Remove GetDateType by key non async * Cleanup some usages of hostingEnvironment.MapPathContentRoot * More easy obsoletion cleanup * Small Typeload cleanup * More obsolete removal * Deploy obsoletion cleanup * Remove obsolete methods from OEmbedProviderBase.cs --------- Co-authored-by: Zeegaan <skrivdetud@gmail.com>
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using NUnit.Framework;
|
|
using Umbraco.Cms.Tests.Common.Testing;
|
|
using Umbraco.Cms.Tests.Integration.Testing;
|
|
|
|
namespace Umbraco.Cms.Tests.Integration.Umbraco.Persistence.EFCore.DbContext;
|
|
|
|
[TestFixture]
|
|
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console)]
|
|
public class CustomDbContextUmbracoProviderTests : UmbracoIntegrationTest
|
|
{
|
|
[Test]
|
|
public void Can_Register_Custom_DbContext_And_Resolve()
|
|
{
|
|
var dbContext = Services.GetRequiredService<CustomDbContext>();
|
|
|
|
Assert.IsNotNull(dbContext);
|
|
Assert.IsNotEmpty(dbContext.Database.GetConnectionString());
|
|
}
|
|
|
|
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
|
{
|
|
builder.Services.AddUmbracoDbContext<CustomDbContext>((serviceProvider, options) =>
|
|
{
|
|
options.UseUmbracoDatabaseProvider(serviceProvider);
|
|
});
|
|
}
|
|
|
|
internal class CustomDbContext : Microsoft.EntityFrameworkCore.DbContext
|
|
{
|
|
public CustomDbContext(DbContextOptions<CustomDbContext> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
[TestFixture]
|
|
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console)]
|
|
public class CustomDbContextCustomSqliteProviderTests : UmbracoIntegrationTest
|
|
{
|
|
[Test]
|
|
public void Can_Register_Custom_DbContext_And_Resolve()
|
|
{
|
|
var dbContext = Services.GetRequiredService<CustomDbContext>();
|
|
|
|
Assert.IsNotNull(dbContext);
|
|
Assert.IsNotEmpty(dbContext.Database.GetConnectionString());
|
|
}
|
|
|
|
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
|
{
|
|
builder.Services.AddUmbracoDbContext<CustomDbContext>((serviceProvider, options) =>
|
|
{
|
|
options.UseSqlite("Data Source=:memory:;Version=3;New=True;");
|
|
});
|
|
}
|
|
|
|
internal class CustomDbContext : Microsoft.EntityFrameworkCore.DbContext
|
|
{
|
|
public CustomDbContext(DbContextOptions<CustomDbContext> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
|