U4-7048 - refresh IFile instances from disk

This commit is contained in:
Stephan
2015-09-07 12:38:46 +02:00
parent b3664d2391
commit e577648efd
18 changed files with 351 additions and 249 deletions

View File

@@ -1,4 +1,6 @@
using System;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using Umbraco.Core.Models;
using Umbraco.Core.Serialization;
@@ -40,9 +42,16 @@ namespace Umbraco.Tests.Models
Assert.AreEqual(clone.Name, item.Name);
Assert.AreEqual(clone.UpdateDate, item.UpdateDate);
//This double verifies by reflection
// clone.Content should be null but getting it would lazy-load
var type = clone.GetType();
var contentField = type.BaseType.GetField("_content", BindingFlags.Instance | BindingFlags.NonPublic);
var value = contentField.GetValue(clone);
Assert.IsNull(value);
// this double verifies by reflection
// need to exclude content else it would lazy-load
var allProps = clone.GetType().GetProperties();
foreach (var propertyInfo in allProps)
foreach (var propertyInfo in allProps.Where(x => x.Name != "Content"))
{
Assert.AreEqual(propertyInfo.GetValue(clone, null), propertyInfo.GetValue(item, null));
}