public void UpdatesLinkFieldValue() { using (GetFakeDb()) { var db = Sitecore.Context.Database; SetupContextDevice(db); var page1 = db.GetItem("/sitecore/content/home/page1"); var page2 = db.GetItem("/sitecore/content/home/page2"); db.GetItem(page2.Fields["Link"].Value).Parent.ID.Should().NotBe(page2.ID); var updater = new TreeReferenceUpdater(); updater.UpdateReferences(page1, page2); db.GetItem(page2.Fields["Link"].Value).Parent.ID.Should().Be(page2.ID); } }
public void UpdatesMultilistFieldValue() { using (GetFakeDb()) { var db = Context.Database; SetupContextDevice(db); var page1 = db.GetItem("/sitecore/content/home/page1"); var page2 = db.GetItem("/sitecore/content/home/page2"); var child1 = page1.Children.First(x => x.Name == "child"); var child2 = page2.Children.First(x => x.Name == "child"); page2.Fields["MultiLink"].Value.Should().Contain(child1.ID.ToString()) .And.NotContain(child2.ID.ToString()); var updater = new TreeReferenceUpdater(); updater.UpdateReferences(page1, page2); page2.Fields["MultiLink"].Value.Should().Contain(child2.ID.ToString()) .And.NotContain(child1.ID.ToString()); } }