Adding integer overload for UmbracoEntity so it can be used with a dynamic object containing either a boolean or integer retrieved from the database to initialize the UmbracoEntity object.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
|
||||
@@ -53,6 +54,12 @@ namespace Umbraco.Core.Models
|
||||
Trashed = trashed;
|
||||
}
|
||||
|
||||
public UmbracoEntity(int trashed)
|
||||
{
|
||||
AdditionalData = new Dictionary<string, object>();
|
||||
Trashed = trashed == 1;
|
||||
}
|
||||
|
||||
public int CreatorId
|
||||
{
|
||||
get { return _creatorId; }
|
||||
|
||||
22
src/Umbraco.Tests/Models/UmbracoEntityTests.cs
Normal file
22
src/Umbraco.Tests/Models/UmbracoEntityTests.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Tests.Models
|
||||
{
|
||||
[TestFixture]
|
||||
public class UmbracoEntityTests
|
||||
{
|
||||
[Test]
|
||||
public void UmbracoEntity_Can_Be_Initialized_From_Dynamic()
|
||||
{
|
||||
var boolIsTrue = true;
|
||||
var intIsTrue = 1;
|
||||
|
||||
var trashedWithBool = new UmbracoEntity((dynamic)boolIsTrue);
|
||||
var trashedWithInt = new UmbracoEntity((dynamic)intIsTrue);
|
||||
|
||||
Assert.IsTrue(trashedWithBool.Trashed);
|
||||
Assert.IsTrue(trashedWithInt.Trashed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,6 +157,7 @@
|
||||
<Compile Include="Membership\MembershipProviderBaseTests.cs" />
|
||||
<Compile Include="Membership\UmbracoServiceMembershipProviderTests.cs" />
|
||||
<Compile Include="MockTests.cs" />
|
||||
<Compile Include="Models\UmbracoEntityTests.cs" />
|
||||
<Compile Include="Mvc\UmbracoViewPageTests.cs" />
|
||||
<Compile Include="Persistence\Auditing\AuditTests.cs" />
|
||||
<Compile Include="BootManagers\CoreBootManagerTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user