Merge remote-tracking branch 'origin/v12/dev' into v13/dev
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NPoco;
|
||||
@@ -14,7 +12,6 @@ using Umbraco.Cms.Persistence.Sqlite.Interceptors;
|
||||
using Umbraco.Cms.Tests.Common.Attributes;
|
||||
using Umbraco.Cms.Tests.Common.Testing;
|
||||
using Umbraco.Cms.Tests.Integration.Testing;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence;
|
||||
|
||||
@@ -125,6 +122,7 @@ public class LocksTests : UmbracoIntegrationTest
|
||||
}
|
||||
}
|
||||
|
||||
[NUnit.Framework.Ignore("We currently do not have a way to force lazy locks")]
|
||||
[Test]
|
||||
public void GivenNonEagerLocking_WhenNoDbIsAccessed_ThenNoSqlIsExecuted()
|
||||
{
|
||||
@@ -154,6 +152,37 @@ public class LocksTests : UmbracoIntegrationTest
|
||||
Assert.AreEqual(0, sqlCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GivenNonEagerLocking_WhenDbIsAccessed_ThenSqlIsExecuted()
|
||||
{
|
||||
var sqlCount = 0;
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var db = ScopeAccessor.AmbientScope.Database;
|
||||
try
|
||||
{
|
||||
db.EnableSqlCount = true;
|
||||
|
||||
// Issue a lock request, but we are using non-eager
|
||||
// locks so this only queues the request.
|
||||
// The lock will not be issued unless we resolve
|
||||
// scope.Database
|
||||
scope.WriteLock(Constants.Locks.Servers);
|
||||
|
||||
scope.Database.ExecuteScalar<int>("SELECT 1");
|
||||
|
||||
sqlCount = db.SqlCount;
|
||||
}
|
||||
finally
|
||||
{
|
||||
db.EnableSqlCount = false;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.AreEqual(2,sqlCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[LongRunning]
|
||||
public void ConcurrentWritersTest()
|
||||
|
||||
Reference in New Issue
Block a user