public void Setup() { _db = global::Sitecore.Configuration.Factory.GetDatabase("master"); Context context = new Context( new AttributeConfigurationLoader( "Glass.Sitecore.Mapper.Tests.Domain, Glass.Sitecore.Mapper.Tests"), null); _service = new SitecoreService(_db); _handler = new SitecoreQueryHandler(); _item = _db.GetItem("/sitecore/content/Data/SitecoreQueryHandler"); }
public void ParseQuery_ReplacesParameters() { //Assign SitecoreQueryHandler handler = new SitecoreQueryHandler(); string query = "/sitecore/content/home/*[@@id='{id}']"; //Act var result = handler.ParseQuery(query, _item); //Assert string expected = "/sitecore/content/home/*[@@id='" + _item.ID.ToString() + "']"; Assert.AreEqual(expected, result); }
public void Setup() { _db = global::Sitecore.Configuration.Factory.GetDatabase("master"); var context = new InstanceContext( (new SitecoreClassConfig[]{ new SitecoreClassConfig(){ ClassAttribute = new SitecoreClassAttribute(), Properties = new SitecoreProperty[]{ new SitecoreProperty(){ Attribute = new SitecoreIdAttribute(), Property = typeof(SitecoreQueryHandlerFixtureNS.TestClass).GetProperty("Id") } }, Type = typeof(SitecoreQueryHandlerFixtureNS.TestClass), DataHandlers = new AbstractSitecoreDataHandler[]{} }, new SitecoreClassConfig(){ ClassAttribute = new SitecoreClassAttribute(), Properties = new SitecoreProperty[]{ new SitecoreProperty(){ Attribute = new SitecoreIdAttribute(), Property = typeof(SitecoreQueryHandlerFixtureNS.BaseType).GetProperty("Id") } }, Type = typeof(SitecoreQueryHandlerFixtureNS.BaseType), DataHandlers = new AbstractSitecoreDataHandler []{ new SitecoreIdDataHandler(){ Property = typeof(SitecoreQueryHandlerFixtureNS.BaseType).GetProperty("Id") } } }, new SitecoreClassConfig(){ ClassAttribute = new SitecoreClassAttribute(){ }, Properties = new SitecoreProperty[]{ new SitecoreProperty(){ Attribute = new SitecoreIdAttribute(), Property = typeof(SitecoreQueryHandlerFixtureNS.TypeOne).GetProperty("Id") } }, Type = typeof(SitecoreQueryHandlerFixtureNS.TypeOne), DataHandlers = new AbstractSitecoreDataHandler []{ new SitecoreIdDataHandler(){ Property = typeof(SitecoreQueryHandlerFixtureNS.TypeOne).GetProperty("Id") } }, TemplateId = new Guid("{5B684B69-F532-4BB2-8A98-02AFCDE4BB84}") }, new SitecoreClassConfig(){ ClassAttribute = new SitecoreClassAttribute(){ }, Properties = new SitecoreProperty[]{ new SitecoreProperty(){ Attribute = new SitecoreIdAttribute(), Property = typeof(SitecoreQueryHandlerFixtureNS.TypeTwo).GetProperty("Id") } }, Type = typeof(SitecoreQueryHandlerFixtureNS.TypeTwo), DataHandlers = new AbstractSitecoreDataHandler []{ new SitecoreIdDataHandler(){ Property = typeof(SitecoreQueryHandlerFixtureNS.TypeTwo).GetProperty("Id") } }, TemplateId = new Guid("{3902F503-7DC7-48B2-9FD8-1EB878CEBA93}") } }).ToDictionary(), new AbstractSitecoreDataHandler[] { }); _service = new SitecoreService(_db, context); _handler = new SitecoreQueryHandler(); _itemId = new Guid("{D22C2A23-DF8A-4EC1-AD52-AE15FE63F937}"); _item = _db.GetItem(new ID(_itemId)); }