public void GetsInferredType_InfersTypeCorrectly() { //Assign Item item = _db.GetItem("/sitecore/content/InstanceContext/Item1"); //Act EmptyTemplate1 temp1 = _service.CreateClass <EmptyTemplate1>(false, true, item); //Assert Assert.IsNotNull(temp1); Assert.IsTrue(temp1 is EmptyTemplate2); }
public void SetFieldValue_ValidClass_ReturnsGuid() { //Assign EmptyTemplate1 target = new EmptyTemplate1(); target.Id = Guid.NewGuid(); SitecoreProperty property = AttributeConfigurationLoader.GetProperty(typeof(RootClass).GetProperty("LazyLoaded")); _handler.ConfigureDataHandler(property); //Act var result = _handler.SetFieldValue(target, _service); //Assert Assert.AreEqual(target.Id, new Guid(result)); }
public void GetsInferredType_InfersTypeCorrectly_WithTwoDifferentClassesDefinedToSupportTheTemplate() { //Assign Item item = _db.GetItem("/sitecore/content/InstanceContext/Item1"); //Act EmptyTemplate1 temp1 = _service.CreateClass <EmptyTemplate1>(false, true, item); InferredTypeBase temp2 = _service.CreateClass <InferredTypeBase>(false, true, item); //Assert Assert.IsNotNull(temp1); Assert.IsTrue(temp1 is EmptyTemplate2); Assert.IsNotNull(temp2); Assert.IsTrue(temp2 is InferredTypeSub); }
public void GetValue_GetsClassUsingId() { //Assign SitecoreItemAttribute attr = new SitecoreItemAttribute(); attr.Id = "{66E62701-3FF2-492D-81A4-BD3E55428837}"; attr.IsLazy = true; SitecoreProperty prop = new SitecoreProperty(); prop.Attribute = attr; prop.Property = new FakePropertyInfo(typeof(EmptyTemplate1)); _handler.ConfigureDataHandler(prop); //Act EmptyTemplate1 result = _handler.GetValue(null, _service) as EmptyTemplate1; //Assert Assert.AreEqual(new Guid(attr.Id), result.Id); }
public void GetValue_GetsClassUsingPath() { //Assign SitecoreItemAttribute attr = new SitecoreItemAttribute(); attr.Path = "/sitecore/content/Data/SitecoreItemHandler/Item1"; attr.IsLazy = true; SitecoreProperty prop = new SitecoreProperty(); prop.Attribute = attr; prop.Property = new FakePropertyInfo(typeof(EmptyTemplate1)); _handler.ConfigureDataHandler(prop); //Act EmptyTemplate1 result = _handler.GetValue(null, _service) as EmptyTemplate1; //Assert Assert.AreEqual(attr.Path, result.Path); }