Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yuriibondar opened this issue Jun 24, 2021 · 0 comments
Open

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

yuriibondar opened this issue Jun 24, 2021 · 0 comments

Comments

@yuriibondar
Copy link

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
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant