Наследование: IDictionaryPhraseRepository
    public void Get_AutocreateIsFalseEntryDoesntExists_ReturnDefaultValue(Db db,[Content]Item rootItem, string relativePath, string defaultValue)
    {
      //Arrange
      var repository = new DictionaryPhraseRepository(new Dictionary() {Root = rootItem, AutoCreate = false});

      //Act
      var result = repository.Get(relativePath, defaultValue);

      //Assert
      result.Should().Be(defaultValue);
    }
    public void GetItem_AutocreateIsFalseEntryDoesntExists_ReturnNull(Db db, [Content]Item rootItem, string relativePath, string defaultValue)
    {
      //Arrange
      var repository = new DictionaryPhraseRepository(new Dictionary() { Root = rootItem, AutoCreate = false, Site = new FakeSiteContext("test")});

      //Act
      var result = repository.GetItem(relativePath, defaultValue);

      //Assert
      result.Should().BeNull();
    }
    public void Get_DatabaseIsNull_ReturnDefaultValue(string relativePath, string defaultValue)
    {
      //Arrange
      Context.Database = null;
      var repository = new DictionaryPhraseRepository(new Dictionary());

      //Act
      var result = repository.Get(relativePath, defaultValue);

      //Assert
      result.Should().Be(defaultValue);
    }
    public void Get_AutocreateIsTrueEntryDoesntExists_ShouldCreateItem(Db db, [Content]CreateDictionaryEntryServiceTests.DictionaryEntryTemplate entryTemplate, [Content]Item rootItem, IEnumerable<string> pathParts, string defaultValue)
    {
      //Arrange
      var relativePath = string.Join("/", pathParts.Select(ItemUtil.ProposeValidItemName));
      var repository = new DictionaryPhraseRepository(new Dictionary() { Root = rootItem, AutoCreate = true });

      //Act
      var result = repository.Get(relativePath, defaultValue);

      //Assert
      result.Should().Be(defaultValue);
      rootItem.Axes.GetItem(relativePath).Should().NotBeNull();
    }
        private static IDictionaryPhraseRepository GetCurrentFromCacheOrCreate()
        {
            if (HttpContext.Current != null)
            {
                var repository = HttpContext.Current.Items["DictionaryPhraseRepository.Current"] as IDictionaryPhraseRepository;
                if (repository != null)
                {
                    return(repository);
                }
            }
            var returnValue = new DictionaryPhraseRepository(DictionaryRepository.Current);

            if (HttpContext.Current != null)
            {
                HttpContext.Current.Items.Add("DictionaryPhraseRepository.Current", returnValue);
            }
            return(returnValue);
        }
    private static IDictionaryPhraseRepository GetCurrentFromCacheOrCreate()
    {
      if (HttpContext.Current != null)
      {
        var repository = HttpContext.Current.Items["DictionaryPhraseRepository.Current"] as IDictionaryPhraseRepository;
        if (repository != null)
        {
          return repository;
        }
      }
      var returnValue = new DictionaryPhraseRepository(DictionaryRepository.Current);

      if (HttpContext.Current != null)
      {
        HttpContext.Current.Items.Add("DictionaryPhraseRepository.Current", returnValue);
      }
      return returnValue;
    }
 public void GetItem_NullRElativePath_ThrowArgumentNullException(string defaultValue)
 {
   var repository = new DictionaryPhraseRepository(new Dictionary());
   repository.Invoking(x => x.GetItem(null, defaultValue)).ShouldThrow<ArgumentNullException>();
 }
    public void Get_IncorrectRelativePath_ThrowArgumentException(Db db, [Content]Item rootItem, string defaultValue)
    {
      //Arrange
      var relativePath = "/";
      var repository = new DictionaryPhraseRepository(new Dictionary() { Root = rootItem, AutoCreate = true });

      //Assert
      repository.Invoking(x=>x.Get(relativePath, defaultValue)).ShouldThrow<ArgumentException>();
    }
    public void Get_AutocreateIsTrueEntryDoesntExists_ShouldreturnItem(Db db, [Content]CreateDictionaryEntryServiceTests.DictionaryEntryTemplate entryTemplate, [Content]Item rootItem, IEnumerable<string> pathParts, string defaultValue)
    {
      //Arrange
      var relativePath = string.Join("/", pathParts);
      var repository = new DictionaryPhraseRepository(new Dictionary() { Root = rootItem, AutoCreate = true });

      //Act
      var result = repository.GetItem(relativePath, defaultValue);

      //Assert
      result[Templates.DictionaryEntry.Fields.Phrase].Should().Be(defaultValue);
    }