Fixes tests, ensures we null check when generating hashes for items in a collection
This commit is contained in:
@@ -44,6 +44,7 @@ namespace Umbraco.Core
|
||||
int hash = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (item == null) continue;
|
||||
hash = 31 * hash + item.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
@@ -57,6 +58,7 @@ namespace Umbraco.Core
|
||||
int hash = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (item == null) continue;
|
||||
hash = 31 * hash + item.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
@@ -77,6 +79,7 @@ namespace Umbraco.Core
|
||||
int count = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (item == null) continue;
|
||||
hash += item.GetHashCode();
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.Cache;
|
||||
using System.Linq;
|
||||
|
||||
namespace Umbraco.Tests.Cache
|
||||
{
|
||||
@@ -31,7 +32,7 @@ namespace Umbraco.Tests.Cache
|
||||
new EventDefinition<ISectionService, EventArgs>(null, ServiceContext.SectionService, new EventArgs(), "Deleted"),
|
||||
new EventDefinition<ISectionService, EventArgs>(null, ServiceContext.SectionService, new EventArgs(), "New"),
|
||||
|
||||
new EventDefinition<IUserService, SaveEventArgs<IUserType>>(null, ServiceContext.UserService, new SaveEventArgs<IUserType>((IUserType) null)),
|
||||
new EventDefinition<IUserService, SaveEventArgs<IUserType>>(null, ServiceContext.UserService, new SaveEventArgs<IUserType>(Enumerable.Empty<IUserType>())),
|
||||
new EventDefinition<IUserService, DeleteEventArgs<IUserType>>(null, ServiceContext.UserService, new DeleteEventArgs<IUserType>((IUserType) null)),
|
||||
|
||||
new EventDefinition<IUserService, SaveEventArgs<IUser>>(null, ServiceContext.UserService, new SaveEventArgs<IUser>((IUser) null)),
|
||||
|
||||
@@ -179,7 +179,9 @@ namespace Umbraco.Tests.Scoping
|
||||
scope.Complete();
|
||||
}
|
||||
|
||||
Assert.AreEqual(complete ? 2 : 0, evented);
|
||||
//The reason why there is only 1 event occuring is because we are publishing twice for the same event for the same
|
||||
//object and the scope deduplicates the events (uses the latest)
|
||||
Assert.AreEqual(complete ? 1 : 0, evented);
|
||||
|
||||
// this should never change
|
||||
Assert.AreEqual(beforeOuterXml, beforeXml.OuterXml);
|
||||
|
||||
Reference in New Issue
Block a user