Skip to content

Adding an item from branch template doesn't work #219

@yuriibondar

Description

@yuriibondar

I was trying to create an item from branch template, using the 2nd example from this page: https://github.com/sshushliapin/Sitecore.FakeDb/wiki/Branches

But parent.Add() method returns null:

public void HowToCreateBranch()
{
  var branchId = Sitecore.Data.ID.NewID;
  var parentId = Sitecore.Data.ID.NewID;

  using (var db = new Sitecore.FakeDb.Db
    {
      new Sitecore.FakeDb.DbItem(
        "Branch Template",
        branchId,
        Sitecore.TemplateIDs.BranchTemplate),

      new Sitecore.FakeDb.DbItem("Parent", parentId)
    })
  {
    var parent = db.GetItem(parentId);
    var child = parent.Add("Child Based on Branch", new Sitecore.Data.BranchId(branchId)); // <-- RETURNS NULL

    // assert
    Xunit.Assert.Equal(branchId, child.BranchId); // <-- FAILS
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions