Merge branch 'test-bases-refactoring' of https://github.com/lars-erik/Umbraco-CMS into lars-erik-test-bases-refactoring
This commit is contained in:
@@ -57,10 +57,10 @@ namespace Umbraco.Tests.Routing
|
||||
public const int LangNlId = 337;
|
||||
public const int LangDkId = 338;
|
||||
|
||||
protected override void SetupApplicationContext()
|
||||
protected override ApplicationContext CreateApplicationContext()
|
||||
{
|
||||
var settings = SettingsForTests.GetDefault();
|
||||
ApplicationContext.Current = new ApplicationContext(
|
||||
return new ApplicationContext(
|
||||
new DatabaseContext(Mock.Of<IDatabaseFactory>(), Logger, Mock.Of<ISqlSyntaxProvider>(), "test"),
|
||||
GetServiceContext(settings, Logger),
|
||||
CacheHelper,
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
private string _dbPath;
|
||||
//used to store (globally) the pre-built db with schema and initial data
|
||||
private static Byte[] _dbBytes;
|
||||
private DefaultDatabaseFactory dbFactory;
|
||||
|
||||
[SetUp]
|
||||
public override void Initialize()
|
||||
@@ -66,27 +67,11 @@ namespace Umbraco.Tests.TestHelpers
|
||||
var path = TestHelper.CurrentAssemblyDirectory;
|
||||
AppDomain.CurrentDomain.SetData("DataDirectory", path);
|
||||
|
||||
//disable cache
|
||||
var cacheHelper = CacheHelper.CreateDisabledCacheHelper();
|
||||
|
||||
var dbFactory = new DefaultDatabaseFactory(
|
||||
dbFactory = new DefaultDatabaseFactory(
|
||||
GetDbConnectionString(),
|
||||
GetDbProviderName(),
|
||||
Logger);
|
||||
|
||||
var repositoryFactory = new RepositoryFactory(cacheHelper, Logger, SqlSyntax, SettingsForTests.GenerateMockSettings());
|
||||
|
||||
var evtMsgs = new TransientMessagesFactory();
|
||||
_appContext = new ApplicationContext(
|
||||
//assign the db context
|
||||
new DatabaseContext(dbFactory, Logger, SqlSyntax, "System.Data.SqlServerCe.4.0"),
|
||||
//assign the service context
|
||||
new ServiceContext(repositoryFactory, new PetaPocoUnitOfWorkProvider(dbFactory), new FileUnitOfWorkProvider(), new PublishingStrategy(evtMsgs, Logger), cacheHelper, Logger, evtMsgs),
|
||||
cacheHelper,
|
||||
ProfilingLogger)
|
||||
{
|
||||
IsReady = true
|
||||
};
|
||||
|
||||
base.Initialize();
|
||||
|
||||
@@ -103,16 +88,32 @@ namespace Umbraco.Tests.TestHelpers
|
||||
}
|
||||
}
|
||||
|
||||
protected override ApplicationContext CreateApplicationContext()
|
||||
{
|
||||
//disable cache
|
||||
var cacheHelper = CacheHelper.CreateDisabledCacheHelper();
|
||||
|
||||
var repositoryFactory = new RepositoryFactory(cacheHelper, Logger, SqlSyntax, SettingsForTests.GenerateMockSettings());
|
||||
|
||||
var evtMsgs = new TransientMessagesFactory();
|
||||
_appContext = new ApplicationContext(
|
||||
//assign the db context
|
||||
new DatabaseContext(dbFactory, Logger, SqlSyntax, "System.Data.SqlServerCe.4.0"),
|
||||
//assign the service context
|
||||
new ServiceContext(repositoryFactory, new PetaPocoUnitOfWorkProvider(dbFactory), new FileUnitOfWorkProvider(), new PublishingStrategy(evtMsgs, Logger), cacheHelper, Logger, evtMsgs),
|
||||
cacheHelper,
|
||||
ProfilingLogger)
|
||||
{
|
||||
IsReady = true
|
||||
};
|
||||
return _appContext;
|
||||
}
|
||||
|
||||
protected virtual ISqlSyntaxProvider SqlSyntax
|
||||
{
|
||||
get { return new SqlCeSyntaxProvider(); }
|
||||
}
|
||||
|
||||
protected override void SetupApplicationContext()
|
||||
{
|
||||
ApplicationContext.Current = _appContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The database behavior to use for the test/fixture
|
||||
/// </summary>
|
||||
|
||||
@@ -149,15 +149,19 @@ namespace Umbraco.Tests.TestHelpers
|
||||
/// </summary>
|
||||
protected virtual void SetupApplicationContext()
|
||||
{
|
||||
var applicationContext = CreateApplicationContext();
|
||||
ApplicationContext.Current = applicationContext;
|
||||
}
|
||||
|
||||
protected virtual ApplicationContext CreateApplicationContext()
|
||||
{
|
||||
var sqlSyntax = new SqlCeSyntaxProvider();
|
||||
var repoFactory = new RepositoryFactory(CacheHelper.CreateDisabledCacheHelper(), Logger, sqlSyntax, SettingsForTests.GenerateMockSettings());
|
||||
|
||||
var evtMsgs = new TransientMessagesFactory();
|
||||
ApplicationContext.Current = new ApplicationContext(
|
||||
var applicationContext = new ApplicationContext(
|
||||
//assign the db context
|
||||
new DatabaseContext(new DefaultDatabaseFactory(Core.Configuration.GlobalSettings.UmbracoConnectionName, Logger),
|
||||
Logger, sqlSyntax, "System.Data.SqlServerCe.4.0"),
|
||||
new DatabaseContext(new DefaultDatabaseFactory(Core.Configuration.GlobalSettings.UmbracoConnectionName, Logger), Logger, sqlSyntax, "System.Data.SqlServerCe.4.0"),
|
||||
//assign the service context
|
||||
new ServiceContext(repoFactory, new PetaPocoUnitOfWorkProvider(Logger), new FileUnitOfWorkProvider(), new PublishingStrategy(evtMsgs, Logger), CacheHelper, Logger, evtMsgs),
|
||||
CacheHelper,
|
||||
@@ -165,6 +169,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
{
|
||||
IsReady = true
|
||||
};
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user