public void QueryRelative_NoResultsReturnsEmptyResult() { //Assign using (Db database = new Db { new Sitecore.FakeDb.DbItem("QueryRelative") { new Sitecore.FakeDb.DbItem("Source"), new Sitecore.FakeDb.DbItem("Target1"), new Sitecore.FakeDb.DbItem("Target2") } }) { var context = Context.Create(Utilities.CreateStandardResolver()); context.Load(new OnDemandLoader <SitecoreTypeConfiguration>(typeof(StubClass))); var path = "/sitecore/content/QueryRelative/Source"; var scContext = new SitecoreContext(); Sitecore.Context.Item = database.GetItem(path); var target1 = database.GetItem("/sitecore/content/QueryRelative/Target1"); var target2 = database.GetItem("/sitecore/content/QueryRelative/Target2"); using (new SecurityDisabler()) { //Act var results = scContext.QueryRelative <StubClass>("/*[@@templatename='notthere']"); //Assert Assert.AreEqual(0, results.Count()); } } }
public void QueryRelative_RetrievesSiblings() { //Assign var db = Sitecore.Configuration.Factory.GetDatabase("master"); var context = Context.Create(Utilities.CreateStandardResolver()); context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration")); var path = "/sitecore/content/Tests/SitecoreContext/QueryRelative/Source"; var scContext = new SitecoreContext(); Sitecore.Context.Item = db.GetItem(path); var target1 = db.GetItem("/sitecore/content/Tests/SitecoreContext/QueryRelative/Target1"); var target2 = db.GetItem("/sitecore/content/Tests/SitecoreContext/QueryRelative/Target2"); //Act var results = scContext.QueryRelative <StubClass>("../*"); //Assert Assert.AreEqual(3, results.Count()); Assert.IsTrue(results.Any(x => x.Id == target1.ID)); Assert.IsTrue(results.Any(x => x.Id == target1.ID)); Assert.IsTrue(results.Any(x => x.Id == Sitecore.Context.Item.ID)); }
public void QueryRelative_RetrievesSiblings() { //Assign using (Db database = new Db { new Sitecore.FakeDb.DbItem("QueryRelative") { new Sitecore.FakeDb.DbItem("Source"), new Sitecore.FakeDb.DbItem("Target1"), new Sitecore.FakeDb.DbItem("Target2") } }) { var context = Context.Create(Utilities.CreateStandardResolver()); context.Load(new OnDemandLoader <SitecoreTypeConfiguration>(typeof(StubClass))); var path = "/sitecore/content/QueryRelative/Source"; var scContext = new SitecoreContext(); Sitecore.Context.Item = database.GetItem(path); var target1 = database.GetItem("/sitecore/content/QueryRelative/Target1"); var target2 = database.GetItem("/sitecore/content/QueryRelative/Target2"); //Act var results = scContext.QueryRelative <StubClass>("../*"); //Assert Assert.AreEqual(3, results.Count()); Assert.IsTrue(results.Any(x => x.Id == target1.ID)); Assert.IsTrue(results.Any(x => x.Id == target2.ID)); Assert.IsTrue(results.Any(x => x.Id == Sitecore.Context.Item.ID)); } }
public void QueryRelative_NoResultsReturnsEmptyResult() { //Assign var db = Sitecore.Configuration.Factory.GetDatabase("master"); var context = Context.Create(Utilities.CreateStandardResolver()); context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration")); var path = "/sitecore/content/Tests/SitecoreContext/QueryRelative/Source"; var scContext = new SitecoreContext(); Sitecore.Context.Item = db.GetItem(path); var target1 = db.GetItem("/sitecore/content/Tests/SitecoreContext/QueryRelative/Target1"); var target2 = db.GetItem("/sitecore/content/Tests/SitecoreContext/QueryRelative/Target2"); using (new SecurityDisabler()) { //Act var results = scContext.QueryRelative <StubClass>("/*[@@templatename='notthere']"); //Assert Assert.AreEqual(0, results.Count()); } }
public void QueryRelative_RetrievesSiblings() { //Assign var db = Sitecore.Configuration.Factory.GetDatabase("master"); var context = Context.Create(Utilities.CreateStandardResolver()); context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration")); var path = "/sitecore/content/Tests/SitecoreContext/QueryRelative/Source"; var scContext = new SitecoreContext(); Sitecore.Context.Item = db.GetItem(path); var target1 = db.GetItem("/sitecore/content/Tests/SitecoreContext/QueryRelative/Target1"); var target2 = db.GetItem("/sitecore/content/Tests/SitecoreContext/QueryRelative/Target2"); //Act var results = scContext.QueryRelative<StubClass>("../*"); //Assert Assert.AreEqual(3, results.Count()); Assert.IsTrue(results.Any(x => x.Id == target1.ID)); Assert.IsTrue(results.Any(x => x.Id == target1.ID)); Assert.IsTrue(results.Any(x => x.Id == Sitecore.Context.Item.ID)); }
public void QueryRelative_NoResultsReturnsEmptyResult() { //Assign using (Db database = new Db { new Sitecore.FakeDb.DbItem("QueryRelative") { new Sitecore.FakeDb.DbItem("Source"), new Sitecore.FakeDb.DbItem("Target1"), new Sitecore.FakeDb.DbItem("Target2") } }) { var context = Context.Create(Utilities.CreateStandardResolver()); context.Load(new OnDemandLoader<SitecoreTypeConfiguration>(typeof(StubClass))); var path = "/sitecore/content/QueryRelative/Source"; var scContext = new SitecoreContext(); Sitecore.Context.Item = database.GetItem(path); var target1 = database.GetItem("/sitecore/content/QueryRelative/Target1"); var target2 = database.GetItem("/sitecore/content/QueryRelative/Target2"); using (new SecurityDisabler()) { //Act var results = scContext.QueryRelative<StubClass>("/*[@@templatename='notthere']"); //Assert Assert.AreEqual(0, results.Count()); } } }
public void QueryRelative_RetrievesSiblings() { //Assign using (Db database = new Db { new Sitecore.FakeDb.DbItem("QueryRelative") { new Sitecore.FakeDb.DbItem("Source"), new Sitecore.FakeDb.DbItem("Target1"), new Sitecore.FakeDb.DbItem("Target2") } }) { var context = Context.Create(Utilities.CreateStandardResolver()); context.Load(new OnDemandLoader<SitecoreTypeConfiguration>(typeof(StubClass))); var path = "/sitecore/content/QueryRelative/Source"; var scContext = new SitecoreContext(); Sitecore.Context.Item = database.GetItem(path); var target1 = database.GetItem("/sitecore/content/QueryRelative/Target1"); var target2 = database.GetItem("/sitecore/content/QueryRelative/Target2"); //Act var results = scContext.QueryRelative<StubClass>("../*"); //Assert Assert.AreEqual(3, results.Count()); Assert.IsTrue(results.Any(x => x.Id == target1.ID)); Assert.IsTrue(results.Any(x => x.Id == target2.ID)); Assert.IsTrue(results.Any(x => x.Id == Sitecore.Context.Item.ID)); } }
public void QueryRelative_NoResultsReturnsEmptyResult() { //Assign var db = Sitecore.Configuration.Factory.GetDatabase("master"); var context = Context.Create(Utilities.CreateStandardResolver()); context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration")); var path = "/sitecore/content/Tests/SitecoreContext/QueryRelative/Source"; var scContext = new SitecoreContext(); Sitecore.Context.Item = db.GetItem(path); var target1 = db.GetItem("/sitecore/content/Tests/SitecoreContext/QueryRelative/Target1"); var target2 = db.GetItem("/sitecore/content/Tests/SitecoreContext/QueryRelative/Target2"); using (new SecurityDisabler()) { //Act var results = scContext.QueryRelative<StubClass>("/*[@@templatename='notthere']"); //Assert Assert.AreEqual(0, results.Count()); } }