U4-9322 - more fixes

This commit is contained in:
Stephan
2017-01-18 17:44:16 +01:00
parent ca777b26de
commit a020a02b26
3 changed files with 7 additions and 4 deletions

View File

@@ -90,6 +90,7 @@ namespace Umbraco.Core.Scoping
var database = ParentScope.Database;
if (_isolationLevel > IsolationLevel.Unspecified && database.CurrentTransactionIsolationLevel < _isolationLevel)
throw new Exception("Scope requires isolation level " + _isolationLevel + ", but got " + database.CurrentTransactionIsolationLevel + " from parent.");
_database = database;
}
if (_database != null)

View File

@@ -64,7 +64,9 @@ namespace Umbraco.Core
// after Umbraco has started there is a scope in "context" and that context is
// going to stay there and never get destroyed nor reused, so we have to ensure that
// the scope is disposed (along with database etc) - reset it all entirely
((ScopeProvider) ApplicationContext.Current.ScopeProvider).Reset();
var scopeProvider = ApplicationContext.Current.ScopeProvider as ScopeProvider;
if (scopeProvider != null) // can be mocked...
scopeProvider.Reset();
}
/// <summary>

View File

@@ -295,7 +295,7 @@ namespace Umbraco.Tests.Scoping
using (var nested = scopeProvider.CreateScope())
{
nested.Database.Execute("INSERT INTO tmp (id, name) VALUES (2, 'b')");
var nn = scope.Database.ExecuteScalar<string>("SELECT name FROM tmp WHERE id=2");
var nn = nested.Database.ExecuteScalar<string>("SELECT name FROM tmp WHERE id=2");
Assert.AreEqual("b", nn);
}
@@ -331,7 +331,7 @@ namespace Umbraco.Tests.Scoping
using (var nested = scopeProvider.CreateScope())
{
nested.Database.Execute("INSERT INTO tmp (id, name) VALUES (2, 'b')");
var nn = scope.Database.ExecuteScalar<string>("SELECT name FROM tmp WHERE id=2");
var nn = nested.Database.ExecuteScalar<string>("SELECT name FROM tmp WHERE id=2");
Assert.AreEqual("b", nn);
nested.Complete();
}
@@ -366,7 +366,7 @@ namespace Umbraco.Tests.Scoping
using (var nested = scopeProvider.CreateScope())
{
nested.Database.Execute("INSERT INTO tmp (id, name) VALUES (2, 'b')");
var nn = scope.Database.ExecuteScalar<string>("SELECT name FROM tmp WHERE id=2");
var nn = nested.Database.ExecuteScalar<string>("SELECT name FROM tmp WHERE id=2");
Assert.AreEqual("b", nn);
nested.Complete();
}