Exemplo n.º 1
0
        private string GetDictionaryFieldValue(string relativePath, string defaultValue)
        {
            //Get Dicitionary Path from Site Root path
            IDictionarySettings dictionarySettings = _sitecoreService.GetItem <IDictionarySettings>(Context.Site?.RootPath);
            var fullPath       = dictionarySettings?.DictionaryPath + relativePath;
            var dictionaryItem = _sitecoreService.GetItem <IDictionaryEntry>(fullPath);

            if (dictionaryItem != null)
            {
                return(dictionaryItem.Phrase ?? defaultValue);
            }
            return(defaultValue);
        }
        public void Get_DictioryItemKeyValue()
        {
            //Arrange
            IDictionarySettings dictionarySettings = Substitute.For <IDictionarySettings>();
            IDictionaryEntry    dictionaryEntry    = Substitute.For <IDictionaryEntry>();

            _testHarness.SitecoreService.GetItem <IDictionarySettings>(Arg.Any <string>()).Returns(dictionarySettings);
            _testHarness.SitecoreService.GetItem <IDictionaryEntry>(Arg.Any <string>()).Returns(dictionaryEntry);

            //Act
            var result = _testHarness.DictionaryPhraseRepository.Get("/blog/LeaveComment", "Hello");

            //Arrange
            result.Should().Equals("Hello");
        }