public void Get_AutocreateNotSet_ReturnFalse([Content] DbItem item, DictionaryRepository repository) { //Arrange var siteContext = new FakeSiteContext(new StringDictionary() { ["dictionaryPath"] = item.FullPath, ["database"] = "master" }); using (new SiteContextSwitcher(siteContext)) { //Act var result = repository.Get(siteContext); //Assert result.AutoCreate.Should().BeFalse(); } }
public void Can_Perform_GetAll_On_DictionaryRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var languageRepository = new LanguageRepository(unitOfWork); var repository = new DictionaryRepository(unitOfWork, languageRepository); // Act var dictionaryItem = repository.Get(1); var dictionaryItems = repository.GetAll(); // Assert Assert.That(dictionaryItems, Is.Not.Null); Assert.That(dictionaryItems.Any(), Is.True); Assert.That(dictionaryItems.Any(x => x == null), Is.False); Assert.That(dictionaryItems.Count(), Is.EqualTo(2)); }
public void Can_Perform_Get_On_DictionaryRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var languageRepository = new LanguageRepository(unitOfWork); var repository = new DictionaryRepository(unitOfWork, languageRepository); // Act var dictionaryItem = repository.Get(1); // Assert Assert.That(dictionaryItem, Is.Not.Null); Assert.That(dictionaryItem.ItemKey, Is.EqualTo("Read More")); Assert.That(dictionaryItem.Translations.Any(), Is.True); Assert.That(dictionaryItem.Translations.Any(x => x == null), Is.False); Assert.That(dictionaryItem.Translations.First().Value, Is.EqualTo("Read More")); Assert.That(dictionaryItem.Translations.Last().Value, Is.EqualTo("Læs mere")); }
public void Can_Perform_Delete_On_DictionaryRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var languageRepository = new LanguageRepository(unitOfWork); var repository = new DictionaryRepository(unitOfWork, languageRepository); // Act var item = repository.Get(1); repository.Delete(item); unitOfWork.Commit(); var exists = repository.Exists(1); // Assert Assert.That(exists, Is.False); }
private IEnumerable <KeyValuePair <string, string> > GetCommunicationPreferencesProperties() { if (contactProfileProvider.CommunicationProfile.CommunicationRevoked) { yield return(new KeyValuePair <string, string>(DictionaryRepository.Get("/Demo/PersonalInfo/CommunicationRevoked", "Communication Revoked"), DictionaryRepository.Get("/Demo/PersonalInfo/CommunicationRevokedTrue", "Yes"))); } if (contactProfileProvider.CommunicationProfile.ConsentRevoked) { yield return(new KeyValuePair <string, string>(DictionaryRepository.Get("/Demo/PersonalInfo/ConsentRevokes", "Consent Revoked"), DictionaryRepository.Get("/Demo/PersonalInfo/ConsentRevokedTrue", "Yes"))); } if (!string.IsNullOrEmpty(contactProfileProvider.Preferences.Language)) { yield return(new KeyValuePair <string, string>(DictionaryRepository.Get("/Demo/PersonalInfo/PreferredLanguage", "Preferred Language"), contactProfileProvider.Preferences.Language)); } }
public ActionResult LinkMenu() { if (string.IsNullOrEmpty(RenderingContext.Current.Rendering.DataSource)) { return(Context.PageMode.IsExperienceEditor ? this.InfoMessage(new InfoMessage(DictionaryRepository.Get("/navigation/linkmenu/noitems", "This menu has no items."), InfoMessage.MessageType.Warning)) : null); } var item = RenderingContext.Current.Rendering.Item; var items = _navigationRepository.GetLinkMenuItems(item); return(View("LinkMenu", items)); }
public static string InvalidDataSourceTemplate(ID templateId) => string.Format(DictionaryRepository.Get("/Alerts/Invalid data source", "Data source isn't set or have wrong template. Template {0} is required"), templateId);
public void Can_Perform_Update_On_DictionaryRepository() { // Arrange var provider = new PetaPocoUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var languageRepository = new LanguageRepository(unitOfWork); var repository = new DictionaryRepository(unitOfWork, languageRepository); // Act var item = repository.Get(1); var translations = item.Translations.ToList(); translations[0].Value = "Read even more"; item.Translations = translations; repository.AddOrUpdate(item); unitOfWork.Commit(); var dictionaryItem = repository.Get(1); // Assert Assert.That(dictionaryItem, Is.Not.Null); Assert.That(dictionaryItem.Translations.Count(), Is.EqualTo(2)); Assert.That(dictionaryItem.Translations.FirstOrDefault().Value, Is.EqualTo("Read even more")); }