public MapToProperty ( AbstractDataMappingContext mappingContext ) : object | ||
mappingContext | AbstractDataMappingContext | The mapping context. |
return | object |
public void MapToProperty_ItemIdAsGuid_ReturnsIdAsGuid() { //Assign string targetPath = "/sitecore/content/target"; using (Db database = new Db { new Sitecore.FakeDb.DbItem("Target") }) { var mapper = new SitecoreIdMapper(); var config = new SitecoreIdConfiguration(); var property = typeof(Stub).GetProperty("GuidId"); var item = database.GetItem("/sitecore/content/target"); Assert.IsNotNull(item, "Item is null, check in Sitecore that item exists"); config.PropertyInfo = property; mapper.Setup(new DataMapperResolverArgs(null, config)); var dataContext = new SitecoreDataMappingContext(null, item, null); var expected = item.ID.Guid; //Act var value = mapper.MapToProperty(dataContext); //Assert Assert.AreEqual(expected, value); } }
public void MapToProperty_ItemIdAsGuid_ReturnsIdAsGuid() { //Assign var mapper = new SitecoreIdMapper(); var config = new SitecoreIdConfiguration(); var property = typeof (Stub).GetProperty("GuidId"); var item = _db.GetItem("/sitecore/content/Tests/DataMappers/SitecoreIdMapper/EmptyItem"); Assert.IsNotNull(item, "Item is null, check in Sitecore that item exists"); config.PropertyInfo = property; mapper.Setup(new DataMapperResolverArgs(null,config)); var dataContext = new SitecoreDataMappingContext(null, item, null); var expected = item.ID.Guid; //Act var value = mapper.MapToProperty(dataContext); //Assert Assert.AreEqual(expected, value); }
public void MapToProperty_ItemIdAsString_ThrowsException() { //Assign var mapper = new SitecoreIdMapper(); var config = new SitecoreIdConfiguration(); var property = typeof(Stub).GetProperty("StringId"); config.PropertyInfo = property; mapper.Setup(new DataMapperResolverArgs(null,config)); var item = _db.GetItem("/sitecore/content/Tests/DataMappers/SitecoreIdMapper/EmptyItem"); Assert.IsNotNull(item, "Item is null, check in Sitecore that item exists"); var dataContext = new SitecoreDataMappingContext(null, item, null); var expected = item.ID; //Act var value = mapper.MapToProperty(dataContext); //Assert //Exception, not asserts }