public void GetValue_ReturnsChildren_UsingLazy() { //Assign Item item = _db.GetItem(_itemPath); SitecoreProperty property = AttributeConfigurationLoader.GetProperty(typeof(ChildrenRoot).GetProperty("Children")); _handler.ConfigureDataHandler(property); //Act var result = _handler.GetValue(item, _service) as Enumerable<EmptyTemplate1>; ChildrenRoot assignTest = new ChildrenRoot(); assignTest.Children = result; //Assert Assert.AreEqual(item.Children.Count, result.Count()); Assert.AreEqual(result, assignTest.Children); //if classes are being loaded lazy they should be of the proxy type and not the concrete type Assert.AreNotEqual(typeof(EmptyTemplate1), result.First().GetType()); //but the proxy inherits from the concrete Assert.IsTrue(result.First() is EmptyTemplate1); }
public void GetValue_ReturnsChildren_UsingLazy() { //Assign Item item = _db.GetItem(_itemPath); SitecoreProperty property = AttributeConfigurationLoader.GetProperty(typeof(ChildrenRoot).GetProperty("Children")); _handler.ConfigureDataHandler(property); //Act var result = _handler.GetValue(item, _service) as Enumerable <EmptyTemplate1>; ChildrenRoot assignTest = new ChildrenRoot(); assignTest.Children = result; //Assert Assert.AreEqual(item.Children.Count, result.Count()); Assert.AreEqual(result, assignTest.Children); //if classes are being loaded lazy they should be of the proxy type and not the concrete type Assert.AreNotEqual(typeof(EmptyTemplate1), result.First().GetType()); //but the proxy inherits from the concrete Assert.IsTrue(result.First() is EmptyTemplate1); }
public void GetValue_ReturnsChildren_NotLazy() { //Assign Item item = _db.GetItem(_itemPath); SitecoreProperty property = AttributeConfigurationLoader.GetProperty(typeof(ChildrenRoot).GetProperty("Children")); property.Attribute.CastTo <SitecoreChildrenAttribute>().IsLazy = false; _handler.ConfigureDataHandler(property); //Act var result = _handler.GetValue(item, _service) as IEnumerable <EmptyTemplate1>; ChildrenRoot assignTest = new ChildrenRoot(); assignTest.Children = result; //Assert Assert.AreEqual(item.Children.Count, result.Count()); Assert.AreEqual(result, assignTest.Children); //if not lazy loaded then the type loaded should be the concrete type Assert.AreEqual(typeof(EmptyTemplate1), result.First().GetType()); Assert.IsTrue(result.First() is EmptyTemplate1); }
public void GetValue_ReturnsChildren_NotLazy() { //Assign Item item = _db.GetItem(_itemPath); SitecoreProperty property = AttributeConfigurationLoader.GetProperty(typeof(ChildrenRoot).GetProperty("Children")); property.Attribute.CastTo<SitecoreChildrenAttribute>().IsLazy = false; _handler.ConfigureDataHandler(property); //Act var result = _handler.GetValue(item, _service) as IEnumerable<EmptyTemplate1>; ChildrenRoot assignTest = new ChildrenRoot(); assignTest.Children = result; //Assert Assert.AreEqual(item.Children.Count, result.Count()); Assert.AreEqual(result, assignTest.Children); //if not lazy loaded then the type loaded should be the concrete type Assert.AreEqual(typeof(EmptyTemplate1), result.First().GetType()); Assert.IsTrue(result.First() is EmptyTemplate1); }