public static Item CreateDictionaryEntry(Dictionary dictionary, string relativePath, string defaultValue)
 {
   lock (dictionary)
   {
     var parts = relativePath.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
     var root = dictionary.Root;
     for (var i = 0; i < parts.Length - 1; i++)
     {
       root = CreateDictionaryFolder(parts[i], root);
     }
     return CreateDictionaryEntry(parts.Last(), root, defaultValue);
   }
 }
    public void CreateDictionaryEntry_Call_CreateItems(Db db,[Content]DictionaryEntryTemplate entryTemplate, [Content]DbItem rootItem, IEnumerable<string> pathParts, string defaultValue)
    {
      //Arrange
      var dictionary = new Dictionary()
      {
        Root = db.GetItem(rootItem.ID)
      };

      var path = string.Join("/", pathParts.Select(ItemUtil.ProposeValidItemName));

      //Act
      var phraseItem = CreateDictionaryEntryService.CreateDictionaryEntry(dictionary, path, defaultValue);

      //Assert
      phraseItem.Should().NotBeNull();
      phraseItem.TemplateID.Should().Be(Templates.DictionaryEntry.ID);
      phraseItem.Paths.FullPath.Should().Be($"{rootItem.FullPath}/{path}");
      phraseItem[Templates.DictionaryEntry.Fields.Phrase].Should().Be(defaultValue);
    }
 public DictionaryPhraseRepository(Dictionary dictionary)
 {
   this.Dictionary = dictionary;
 }