public void ReplaceItemReferences_ItemPassed_ShouldReplaceID(ItemReferenceReplacer referenceReplacer, Db db, [Content] Item source, [Content] Item target)
    {
      var initialValue = source.ID.ToString();
      var expectedValue = target.ID.ToString();

      ReplaceItemReferences_ItemPassed_ShouldReplaceValue(referenceReplacer, db, source, target, initialValue, expectedValue);
    }
    public void ReplaceItemReferences_ItemPassed_ShouldReplaceContentPath(ItemReferenceReplacer referenceReplacer, Db db, [Content] Item source, [Content] Item target)
    {
      var initialValue = source.Paths.ContentPath;
      var expectedValue = target.Paths.ContentPath;

      ReplaceItemReferences_ItemPassed_ShouldReplaceValue(referenceReplacer, db, source, target, initialValue, expectedValue);
    }
    private static void ReplaceItemReferences_ItemPassed_ShouldReplaceValue(ItemReferenceReplacer referenceReplacer, Db db, Item source, Item target, string initialValue, string expectedValue)
    {
      referenceReplacer.AddItemPair(source, target);

      db.Add(new DbItem("testItem")
      {
        {
          "targetField", initialValue
        }
      });
      var item = db.GetItem("/sitecore/content/testItem");
      referenceReplacer.ReplaceItemReferences(item);
      item["targetField"].Should().Be(expectedValue);
    }
        public void Update()
        {
            var referenceReplacer = new ItemReferenceReplacer();
            var dependencies      = this.Source.GetLocalDatasourceDependencies();

            foreach (var sourceDependencyItem in dependencies)
            {
                var targetDependencyItem = this.GetTargetDependency(sourceDependencyItem);
                if (targetDependencyItem == null)
                {
                    Log.Warn($"ChangeLocalDatasourceReferences: Could not resolve {sourceDependencyItem.Paths.FullPath} on {this.Target.Paths.FullPath}", this);
                    continue;
                }
                referenceReplacer.AddItemPair(sourceDependencyItem, targetDependencyItem);
            }
            referenceReplacer.ReplaceItemReferences(this.Target);
        }