Skip to content

Creating a Hierarchy of Items

sergeyshushlyapin edited this page Nov 6, 2014 · 2 revisions

This code creates a root item Articles and two child items - Getting Started and Troubleshooting:

[Fact]
public void HowToCreateHierarchyOfItems()
{
  using (Sitecore.FakeDb.Db db = new Sitecore.FakeDb.Db
    {
      new Sitecore.FakeDb.DbItem("Articles")
        {
          new Sitecore.FakeDb.DbItem("Getting Started"),
          new Sitecore.FakeDb.DbItem("Troubleshooting")
        }
    })
  {
    Sitecore.Data.Items.Item articles =
      db.GetItem("/sitecore/content/Articles");

    Xunit.Assert.NotNull(articles.Children["Getting Started"]);
    Xunit.Assert.NotNull(articles.Children["Troubleshooting"]);
  }
}
Clone this wiki locally