Adjust unit tests and apply fixes to scope
This commit is contained in:
@@ -519,7 +519,26 @@ namespace Umbraco.Core.Scoping
|
||||
{
|
||||
if (ParentScope is null)
|
||||
{
|
||||
WriteLocks[instanceId][lockId]++;
|
||||
// Try and get the dict associated with the scope id.
|
||||
var locksDictFound = WriteLocks.TryGetValue(instanceId, out var locksDict);
|
||||
if (locksDictFound)
|
||||
{
|
||||
var lockFound = locksDict.TryGetValue(lockId, out var value);
|
||||
if (lockFound)
|
||||
{
|
||||
WriteLocks[instanceId][lockId] = value+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLocks[instanceId][lockId] = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The scope hasn't requested a lock yet, so we have to create a dict for it.
|
||||
WriteLocks[instanceId] = new Dictionary<int, int>();
|
||||
WriteLocks[instanceId][lockId] = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -543,7 +562,25 @@ namespace Umbraco.Core.Scoping
|
||||
{
|
||||
if (ParentScope is null)
|
||||
{
|
||||
ReadLocks[instanceId][lockId]++;
|
||||
var locksDictFound = ReadLocks.TryGetValue(instanceId, out var locksDict);
|
||||
if (locksDictFound)
|
||||
{
|
||||
var lockFound = locksDict.TryGetValue(lockId, out var value);
|
||||
if (lockFound)
|
||||
{
|
||||
ReadLocks[instanceId][lockId] = value + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadLocks[instanceId][lockId] = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The scope hasn't requested a lock yet, so we have to create a dict for it.
|
||||
ReadLocks[instanceId] = new Dictionary<int, int>();
|
||||
ReadLocks[instanceId][lockId] = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -721,11 +758,13 @@ namespace Umbraco.Core.Scoping
|
||||
catch
|
||||
{
|
||||
DecrementWriteLock(lockId, instanceId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DecrementWriteLock(lockId, instanceId);
|
||||
// We already have a lock, so just increment the count for debugging purposes
|
||||
IncrementWriteLock(lockId, instanceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,27 +180,30 @@ namespace Umbraco.Tests.Scoping
|
||||
public void WriteLocks_Count_correctly_If_Lock_Requested_Twice_In_Scope()
|
||||
{
|
||||
var scopeProvider = GetScopeProvider(out var syntaxProviderMock);
|
||||
Guid innerscopeId;
|
||||
|
||||
using (var outerscope = scopeProvider.CreateScope())
|
||||
{
|
||||
var realOuterScope = (Scope) outerscope;
|
||||
outerscope.WriteLock(Constants.Locks.ContentTree);
|
||||
outerscope.WriteLock(Constants.Locks.ContentTree);
|
||||
Assert.AreEqual(2, realOuterScope.WriteLocks[Constants.Locks.ContentTree]);
|
||||
Assert.AreEqual(2, realOuterScope.WriteLocks[outerscope.InstanceId][Constants.Locks.ContentTree]);
|
||||
|
||||
using (var innerScope = scopeProvider.CreateScope())
|
||||
{
|
||||
innerscopeId = innerScope.InstanceId;
|
||||
innerScope.WriteLock(Constants.Locks.ContentTree);
|
||||
innerScope.WriteLock(Constants.Locks.ContentTree);
|
||||
Assert.AreEqual(4, realOuterScope.WriteLocks[Constants.Locks.ContentTree]);
|
||||
Assert.AreEqual(2, realOuterScope.WriteLocks[outerscope.InstanceId][Constants.Locks.ContentTree]);
|
||||
Assert.AreEqual(2, realOuterScope.WriteLocks[innerscopeId][Constants.Locks.ContentTree]);
|
||||
|
||||
innerScope.WriteLock(Constants.Locks.Languages);
|
||||
innerScope.WriteLock(Constants.Locks.Languages);
|
||||
Assert.AreEqual(2, realOuterScope.WriteLocks[Constants.Locks.Languages]);
|
||||
Assert.AreEqual(2, realOuterScope.WriteLocks[innerScope.InstanceId][Constants.Locks.Languages]);
|
||||
innerScope.Complete();
|
||||
}
|
||||
Assert.AreEqual(0, realOuterScope.WriteLocks[Constants.Locks.Languages]);
|
||||
Assert.AreEqual(2, realOuterScope.WriteLocks[Constants.Locks.ContentTree]);
|
||||
Assert.IsFalse(realOuterScope.WriteLocks.ContainsKey(innerscopeId));
|
||||
Assert.AreEqual(2, realOuterScope.WriteLocks[realOuterScope.InstanceId][Constants.Locks.ContentTree]);
|
||||
outerscope.Complete();
|
||||
}
|
||||
}
|
||||
@@ -209,27 +212,30 @@ namespace Umbraco.Tests.Scoping
|
||||
public void ReadLocks_Count_correctly_If_Lock_Requested_Twice_In_Scope()
|
||||
{
|
||||
var scopeProvider = GetScopeProvider(out var syntaxProviderMock);
|
||||
Guid innerscopeId;
|
||||
|
||||
using (var outerscope = scopeProvider.CreateScope())
|
||||
{
|
||||
var realOuterScope = (Scope) outerscope;
|
||||
outerscope.ReadLock(Constants.Locks.ContentTree);
|
||||
outerscope.ReadLock(Constants.Locks.ContentTree);
|
||||
Assert.AreEqual(2, realOuterScope.ReadLocks[Constants.Locks.ContentTree]);
|
||||
Assert.AreEqual(2, realOuterScope.ReadLocks[outerscope.InstanceId][Constants.Locks.ContentTree]);
|
||||
|
||||
using (var innerScope = scopeProvider.CreateScope())
|
||||
{
|
||||
innerscopeId = innerScope.InstanceId;
|
||||
innerScope.ReadLock(Constants.Locks.ContentTree);
|
||||
innerScope.ReadLock(Constants.Locks.ContentTree);
|
||||
Assert.AreEqual(4, realOuterScope.ReadLocks[Constants.Locks.ContentTree]);
|
||||
Assert.AreEqual(2, realOuterScope.ReadLocks[outerscope.InstanceId][Constants.Locks.ContentTree]);
|
||||
Assert.AreEqual(2, realOuterScope.ReadLocks[innerScope.InstanceId][Constants.Locks.ContentTree]);
|
||||
|
||||
innerScope.ReadLock(Constants.Locks.Languages);
|
||||
innerScope.ReadLock(Constants.Locks.Languages);
|
||||
Assert.AreEqual(2, realOuterScope.ReadLocks[Constants.Locks.Languages]);
|
||||
Assert.AreEqual(2, realOuterScope.ReadLocks[innerScope.InstanceId][Constants.Locks.Languages]);
|
||||
innerScope.Complete();
|
||||
}
|
||||
Assert.AreEqual(0, realOuterScope.ReadLocks[Constants.Locks.Languages]);
|
||||
Assert.AreEqual(2, realOuterScope.ReadLocks[Constants.Locks.ContentTree]);
|
||||
Assert.IsFalse(realOuterScope.ReadLocks.ContainsKey(innerscopeId));
|
||||
Assert.AreEqual(2, realOuterScope.ReadLocks[outerscope.InstanceId][Constants.Locks.ContentTree]);
|
||||
outerscope.Complete();
|
||||
}
|
||||
}
|
||||
@@ -238,51 +244,60 @@ namespace Umbraco.Tests.Scoping
|
||||
public void Nested_Scopes_WriteLocks_Count_Correctly()
|
||||
{
|
||||
var scopeProvider = GetScopeProvider(out var syntaxProviderMock);
|
||||
Guid innerScope1Id, innerScope2Id;
|
||||
|
||||
using (var outerScope = scopeProvider.CreateScope())
|
||||
using (var parentScope = scopeProvider.CreateScope())
|
||||
{
|
||||
var parentScope = (Scope) outerScope;
|
||||
outerScope.WriteLock(Constants.Locks.ContentTree);
|
||||
outerScope.WriteLock(Constants.Locks.ContentTypes);
|
||||
var realParentScope = (Scope) parentScope;
|
||||
parentScope.WriteLock(Constants.Locks.ContentTree);
|
||||
parentScope.WriteLock(Constants.Locks.ContentTypes);
|
||||
|
||||
Assert.AreEqual(1, parentScope.WriteLocks[Constants.Locks.ContentTree], $"parentScope after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, parentScope.WriteLocks[Constants.Locks.ContentTypes], $"parentScope after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[realParentScope.InstanceId][Constants.Locks.ContentTree], $"parentScope after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[realParentScope.InstanceId][Constants.Locks.ContentTypes], $"parentScope after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
|
||||
using (var innerScope1 = scopeProvider.CreateScope())
|
||||
{
|
||||
innerScope1Id = innerScope1.InstanceId;
|
||||
innerScope1.WriteLock(Constants.Locks.ContentTree);
|
||||
innerScope1.WriteLock(Constants.Locks.ContentTypes);
|
||||
innerScope1.WriteLock(Constants.Locks.Languages);
|
||||
|
||||
Assert.AreEqual(2, parentScope.WriteLocks[Constants.Locks.ContentTree], $"childScope1 after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(2, parentScope.WriteLocks[Constants.Locks.ContentTypes], $"childScope1 after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, parentScope.WriteLocks[Constants.Locks.Languages], $"childScope1 after locks acquired: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[realParentScope.InstanceId][Constants.Locks.ContentTree], $"innerScope1, parent instance, after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[realParentScope.InstanceId][Constants.Locks.ContentTypes], $"innerScope1, parent instance, after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope1.InstanceId][Constants.Locks.ContentTree], $"innerScope1, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope1.InstanceId][Constants.Locks.ContentTypes], $"innerScope1, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope1.InstanceId][Constants.Locks.Languages], $"innerScope1, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.Languages)}");
|
||||
|
||||
using (var innerScope2 = scopeProvider.CreateScope())
|
||||
{
|
||||
innerScope2Id = innerScope2.InstanceId;
|
||||
innerScope2.WriteLock(Constants.Locks.ContentTree);
|
||||
innerScope2.WriteLock(Constants.Locks.MediaTypes);
|
||||
|
||||
Assert.AreEqual(3, parentScope.WriteLocks[Constants.Locks.ContentTree], $"childScope2 after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(2, parentScope.WriteLocks[Constants.Locks.ContentTypes], $"childScope2 after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, parentScope.WriteLocks[Constants.Locks.Languages], $"childScope2 after locks acquired: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.AreEqual(1, parentScope.WriteLocks[Constants.Locks.MediaTypes], $"childScope2 after locks acquired: {nameof(Constants.Locks.MediaTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[realParentScope.InstanceId][Constants.Locks.ContentTree], $"innerScope2, parent instance, after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[realParentScope.InstanceId][Constants.Locks.ContentTypes], $"innerScope2, parent instance, after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope1.InstanceId][Constants.Locks.ContentTree], $"innerScope2, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope1.InstanceId][Constants.Locks.ContentTypes], $"innerScope2, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope1.InstanceId][Constants.Locks.Languages], $"innerScope2, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope2.InstanceId][Constants.Locks.ContentTree], $"innerScope2, innerScope2 instance, after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope2.InstanceId][Constants.Locks.MediaTypes], $"innerScope2, innerScope2 instance, after locks acquired: {nameof(Constants.Locks.MediaTypes)}");
|
||||
|
||||
innerScope2.Complete();
|
||||
}
|
||||
Assert.AreEqual(2, parentScope.WriteLocks[Constants.Locks.ContentTree], $"childScope1 after inner scope disposed: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(2, parentScope.WriteLocks[Constants.Locks.ContentTypes], $"childScope1 after inner scope disposed: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, parentScope.WriteLocks[Constants.Locks.Languages], $"childScope1 after inner scope disposed: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.AreEqual(0, parentScope.WriteLocks[Constants.Locks.MediaTypes], $"childScope1 after inner scope disposed: {nameof(Constants.Locks.MediaTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[realParentScope.InstanceId][Constants.Locks.ContentTree], $"innerScope2, parent instance, after innserScope2 disposed: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[realParentScope.InstanceId][Constants.Locks.ContentTypes], $"innerScope2, parent instance, after innserScope2 disposed: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope1.InstanceId][Constants.Locks.ContentTree], $"innerScope2, innerScope1 instance, after innserScope2 disposed: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope1.InstanceId][Constants.Locks.ContentTypes], $"innerScope2, innerScope1 instance, after innserScope2 disposed: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[innerScope1.InstanceId][Constants.Locks.Languages], $"innerScope2, innerScope1 instance, after innserScope2 disposed: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.IsFalse(realParentScope.WriteLocks.ContainsKey(innerScope2Id));
|
||||
|
||||
innerScope1.Complete();
|
||||
}
|
||||
Assert.AreEqual(1, parentScope.WriteLocks[Constants.Locks.ContentTree], $"parentScope after inner scopes disposed: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, parentScope.WriteLocks[Constants.Locks.ContentTypes], $"parentScope after inner scopes disposed: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(0, parentScope.WriteLocks[Constants.Locks.Languages], $"parentScope after inner scopes disposed: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.AreEqual(0, parentScope.WriteLocks[Constants.Locks.MediaTypes], $"parentScope after inner scopes disposed: {nameof(Constants.Locks.MediaTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[realParentScope.InstanceId][Constants.Locks.ContentTree], $"parentScope after inner scopes disposed: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.WriteLocks[realParentScope.InstanceId][Constants.Locks.ContentTypes], $"parentScope after inner scopes disposed {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.IsFalse(realParentScope.WriteLocks.ContainsKey(innerScope1Id));
|
||||
|
||||
outerScope.Complete();
|
||||
parentScope.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,48 +305,59 @@ namespace Umbraco.Tests.Scoping
|
||||
public void Nested_Scopes_ReadLocks_Count_Correctly()
|
||||
{
|
||||
var scopeProvider = GetScopeProvider(out var syntaxProviderMock);
|
||||
Guid innerScope1Id, innerScope2Id;
|
||||
|
||||
using (var outerScope = scopeProvider.CreateScope())
|
||||
using (var parentScope = scopeProvider.CreateScope())
|
||||
{
|
||||
var parentScope = (Scope) outerScope;
|
||||
outerScope.ReadLock(Constants.Locks.ContentTree);
|
||||
outerScope.ReadLock(Constants.Locks.ContentTypes);
|
||||
Assert.AreEqual(1, parentScope.ReadLocks[Constants.Locks.ContentTree], $"parentScope after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, parentScope.ReadLocks[Constants.Locks.ContentTypes], $"parentScope after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
var realParentScope = (Scope) parentScope;
|
||||
parentScope.ReadLock(Constants.Locks.ContentTree);
|
||||
parentScope.ReadLock(Constants.Locks.ContentTypes);
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[realParentScope.InstanceId][Constants.Locks.ContentTree], $"parentScope after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[realParentScope.InstanceId][Constants.Locks.ContentTypes], $"parentScope after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
|
||||
using (var innserScope1 = scopeProvider.CreateScope())
|
||||
{
|
||||
innerScope1Id = innserScope1.InstanceId;
|
||||
innserScope1.ReadLock(Constants.Locks.ContentTree);
|
||||
innserScope1.ReadLock(Constants.Locks.ContentTypes);
|
||||
innserScope1.ReadLock(Constants.Locks.Languages);
|
||||
Assert.AreEqual(2, parentScope.ReadLocks[Constants.Locks.ContentTree], $"childScope1 after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(2, parentScope.ReadLocks[Constants.Locks.ContentTypes], $"childScope1 after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, parentScope.ReadLocks[Constants.Locks.Languages], $"childScope1 after locks acquired: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[realParentScope.InstanceId][Constants.Locks.ContentTree], $"innerScope1, parent instance, after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[realParentScope.InstanceId][Constants.Locks.ContentTypes], $"innerScope1, parent instance, after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innserScope1.InstanceId][Constants.Locks.ContentTree], $"innerScope1, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innserScope1.InstanceId][Constants.Locks.ContentTypes], $"innerScope1, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innserScope1.InstanceId][Constants.Locks.Languages], $"innerScope1, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.Languages)}");
|
||||
|
||||
using (var innerScope2 = scopeProvider.CreateScope())
|
||||
{
|
||||
innerScope2Id = innerScope2.InstanceId;
|
||||
innerScope2.ReadLock(Constants.Locks.ContentTree);
|
||||
innerScope2.ReadLock(Constants.Locks.MediaTypes);
|
||||
Assert.AreEqual(3, parentScope.ReadLocks[Constants.Locks.ContentTree], $"childScope2 after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(2, parentScope.ReadLocks[Constants.Locks.ContentTypes], $"childScope2 after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, parentScope.ReadLocks[Constants.Locks.Languages], $"childScope2 after locks acquired: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.AreEqual(1, parentScope.ReadLocks[Constants.Locks.MediaTypes], $"childScope2 after locks acquired: {nameof(Constants.Locks.MediaTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[realParentScope.InstanceId][Constants.Locks.ContentTree], $"innerScope2, parent instance, after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[realParentScope.InstanceId][Constants.Locks.ContentTypes], $"innerScope2, parent instance, after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innserScope1.InstanceId][Constants.Locks.ContentTree], $"innerScope2, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innserScope1.InstanceId][Constants.Locks.ContentTypes], $"innerScope2, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innserScope1.InstanceId][Constants.Locks.Languages], $"innerScope2, innerScope1 instance, after locks acquired: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innerScope2.InstanceId][Constants.Locks.ContentTree], $"innerScope2, innerScope2 instance, after locks acquired: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innerScope2.InstanceId][Constants.Locks.MediaTypes], $"innerScope2, innerScope2 instance, after locks acquired: {nameof(Constants.Locks.MediaTypes)}");
|
||||
|
||||
innerScope2.Complete();
|
||||
}
|
||||
Assert.AreEqual(2, parentScope.ReadLocks[Constants.Locks.ContentTree], $"childScope1 after inner scope disposed: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(2, parentScope.ReadLocks[Constants.Locks.ContentTypes], $"childScope1 after inner scope disposed: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, parentScope.ReadLocks[Constants.Locks.Languages], $"childScope1 after inner scope disposed: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.AreEqual(0, parentScope.ReadLocks[Constants.Locks.MediaTypes], $"childScope1 after inner scope disposed: {nameof(Constants.Locks.MediaTypes)}");
|
||||
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[realParentScope.InstanceId][Constants.Locks.ContentTree], $"innerScope1, parent instance, after innerScope2 disposed: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[realParentScope.InstanceId][Constants.Locks.ContentTypes], $"innerScope1, parent instance, after innerScope2 disposed: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innserScope1.InstanceId][Constants.Locks.ContentTree], $"innerScope1, innerScope1 instance, after innerScope2 disposed: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innserScope1.InstanceId][Constants.Locks.ContentTypes], $"innerScope1, innerScope1 instance, after innerScope2 disposed: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[innserScope1.InstanceId][Constants.Locks.Languages], $"innerScope1, innerScope1 instance, after innerScope2 disposed: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.IsFalse(realParentScope.ReadLocks.ContainsKey(innerScope2Id));
|
||||
|
||||
innserScope1.Complete();
|
||||
}
|
||||
Assert.AreEqual(1, parentScope.ReadLocks[Constants.Locks.ContentTree], $"parentScope after inner scopes disposed: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, parentScope.ReadLocks[Constants.Locks.ContentTypes], $"parentScope after inner scopes disposed: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.AreEqual(0, parentScope.ReadLocks[Constants.Locks.Languages], $"parentScope after inner scopes disposed: {nameof(Constants.Locks.Languages)}");
|
||||
Assert.AreEqual(0, parentScope.ReadLocks[Constants.Locks.MediaTypes], $"parentScope after inner scopes disposed: {nameof(Constants.Locks.MediaTypes)}");
|
||||
|
||||
outerScope.Complete();
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[realParentScope.InstanceId][Constants.Locks.ContentTree], $"parentScope after innerScope1 disposed: {nameof(Constants.Locks.ContentTree)}");
|
||||
Assert.AreEqual(1, realParentScope.ReadLocks[realParentScope.InstanceId][Constants.Locks.ContentTypes], $"parentScope after innerScope1 disposed: {nameof(Constants.Locks.ContentTypes)}");
|
||||
Assert.IsFalse(realParentScope.ReadLocks.ContainsKey(innerScope1Id));
|
||||
|
||||
parentScope.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user