Skip to content

Commit

Permalink
Fix StandaloneTests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan committed May 16, 2019
1 parent 206f47b commit 5dbc95a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Umbraco.Tests/Runtimes/StandaloneTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using Umbraco.Tests.Testing.Objects.Accessors;
using Umbraco.Web;
using Umbraco.Web.Cache;
using Umbraco.Web.Macros;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
using Umbraco.Web.Runtime;
Expand Down Expand Up @@ -81,7 +82,7 @@ public void StandaloneTest()

var composerTypes = typeLoader.GetTypes<IComposer>() // all of them
.Where(x => !x.FullName.StartsWith("Umbraco.Tests.")) // exclude test components
.Where(x => x != typeof(WebInitialComposer)); // exclude web runtime
.Where(x => x != typeof(WebInitialComposer) && x != typeof(WebFinalComposer)); // exclude web runtime
var composers = new Composers(composition, composerTypes, profilingLogger);
composers.Compose();

Expand All @@ -101,6 +102,8 @@ public void StandaloneTest()
composition.RegisterUnique<IDistributedCacheBinder, DistributedCacheBinder>();
composition.RegisterUnique<IExamineManager>(f => ExamineManager.Instance);
composition.RegisterUnique<IUmbracoContextFactory, UmbracoContextFactory>();
composition.RegisterUnique<IMacroRenderer, MacroRenderer>();
composition.RegisterUnique<MediaUrlProviderCollection>(_ => new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()));

// initialize some components only/individually
composition.WithCollectionBuilder<ComponentCollectionBuilder>()
Expand All @@ -124,14 +127,15 @@ public void StandaloneTest()
if (true || runtimeState.Level == RuntimeLevel.Install)
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var file = Path.Combine(path, "Umbraco.sdf");
var file = databaseFactory.Configured ? Path.Combine(path, "UmbracoNPocoTests.sdf") : Path.Combine(path, "Umbraco.sdf");
if (File.Exists(file))
File.Delete(file);

// create the database file
// databaseBuilder.ConfigureEmbeddedDatabaseConnection() can do it too,
// but then it wants to write the connection string to web.config = bad
using (var engine = new SqlCeEngine("Data Source=|DataDirectory|\\Umbraco.sdf;Flush Interval=1;"))
var connectionString = databaseFactory.Configured ? databaseFactory.ConnectionString : "Data Source=|DataDirectory|\\Umbraco.sdf;Flush Interval=1;";
using (var engine = new SqlCeEngine(connectionString))
{
engine.CreateDatabase();
}
Expand All @@ -140,7 +144,8 @@ public void StandaloneTest()
//databaseFactory.Configure(DatabaseBuilder.EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe);
//databaseBuilder.CreateDatabaseSchemaAndData();

databaseFactory.Configure(DatabaseBuilder.EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe);
if (!databaseFactory.Configured)
databaseFactory.Configure(DatabaseBuilder.EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe);

var scopeProvider = factory.GetInstance<IScopeProvider>();
using (var scope = scopeProvider.CreateScope())
Expand All @@ -154,6 +159,8 @@ public void StandaloneTest()
// done installing
runtimeState.Level = RuntimeLevel.Run;

components.Initialize();

// instantiate to register events
// should be done by Initialize?
// should we invoke Initialize?
Expand Down

0 comments on commit 5dbc95a

Please sign in to comment.