private void AddTestData(ServiceProvider container) { var cultureUoW = container.GetRequiredService <CultureUoW>(); cultureUoW.AddCulture("cs"); cultureUoW.AddCulture("en"); cultureUoW.AddCulture("es"); cultureUoW.AddCulture("jp"); cultureUoW.AddCulture("ru"); var scopeUoW = container.GetRequiredService <DictionaryScopeUoW>(); scopeUoW.AddScope("home"); scopeUoW.AddScope("global"); var now = DateTime.UtcNow; var staticTextUoW = container.GetRequiredService <StaticTextUoW>(); m_staticTextUoW = staticTextUoW; staticTextUoW.AddStaticText("support", 0, "Podpora", "cs", "home", "user", now); staticTextUoW.AddStaticText("about", 0, "O portálu", "cs", "home", "user", now); staticTextUoW.AddStaticText("copyright", 0, "Copyright", "cs", "home", "user", now); staticTextUoW.AddStaticText("contacts", 0, "Kontakty", "cs", "home", "user", now); staticTextUoW.AddStaticText("links", 0, "Odkazy", "cs", "home", "user", now); staticTextUoW.AddStaticText("howtocite", 0, "Jak citovat", "cs", "home", "user", now); staticTextUoW.AddStaticText("feedback", 0, "Připomínky", "cs", "home", "user", now); staticTextUoW.AddStaticText("cancel", 0, "Zrušit", "cs", "home", "user", now); }
public void StaticTextCreateReadTest() { var cultureUoW = new CultureUoW(m_sessionFactory); var dictionaryScopeUoW = new DictionaryScopeUoW(m_sessionFactory); var staticTextUoW = new StaticTextUoW(m_sessionFactory); cultureUoW.AddCulture("cs"); dictionaryScopeUoW.AddScope("dictionaryScope"); Assert.IsNull(staticTextUoW.GetStaticTextById(0)); Assert.IsNull(staticTextUoW.GetByNameAndCultureAndScope("not-exist", "not-exist", "not-exist")); var time = DateTime.UtcNow; staticTextUoW.AddStaticText( "name", 0, "text", "cs", "dictionaryScope", "modificationUser", time ); var allStaticTexts = staticTextUoW.FindAllStaticTexts(); Assert.AreEqual(1, allStaticTexts.Count); Assert.AreEqual("name", allStaticTexts.First().Name); Assert.AreEqual("name", staticTextUoW.GetStaticTextById(1).Name); var staticText = staticTextUoW.GetByNameAndCultureAndScope( "name", "cs", "dictionaryScope" ); Assert.AreEqual("name", staticText.Name); Assert.AreEqual("text", staticText.Text); var nullStaticText1 = staticTextUoW.GetByNameAndCultureAndScope( "not-exist", "cs", "dictionaryScope" ); var nullStaticText2 = staticTextUoW.GetByNameAndCultureAndScope( "name", "en", "dictionaryScope" ); var nullStaticText3 = staticTextUoW.GetByNameAndCultureAndScope( "name", "cs", "not-exist" ); Assert.IsNull(nullStaticText1); Assert.IsNull(nullStaticText2); Assert.IsNull(nullStaticText3); }
public DatabaseDynamicTextService( StaticTextUoW staticTextUoW, LocalizationConfiguration configuration, CultureUoW cultureUoW, DictionaryScopeUoW dictionaryScopeUoW, ILogger <DatabaseDynamicTextService> logger, IMemoryCache memoryCache ) : base(configuration, cultureUoW, dictionaryScopeUoW, logger, memoryCache) { m_staticTextUoW = staticTextUoW; }
public DatabaseDictionaryService( LocalizationConfiguration configuration, CultureUoW cultureUoW, StaticTextUoW staticTextUoW, PluralizedStaticTextUoW pluralizedStaticTextUoW, ConstantStaticTextUoW constantStaticTextUoW, DictionaryScopeUoW dictionaryScopeUoW, ILogger <DatabaseDictionaryService> logger, IMemoryCache memoryCache ) : base(configuration, cultureUoW, dictionaryScopeUoW, logger, memoryCache) { m_staticTextUoW = staticTextUoW; m_pluralizedStaticTextUoW = pluralizedStaticTextUoW; m_constantStaticTextUoW = constantStaticTextUoW; }
public DatabaseTranslateService( FallbackCultureResolver fallbackCultureResolver, CultureHierarchyUoW cultureHierarchyUoW, StaticTextUoW staticTextUoW, LocalizationConfiguration configuration, CultureUoW cultureUoW, DictionaryScopeUoW dictionaryScopeUoW, ILogger <DatabaseTranslateService> logger, IMemoryCache memoryCache ) : base(configuration, cultureUoW, dictionaryScopeUoW, logger, memoryCache) { m_fallbackCultureResolver = fallbackCultureResolver; m_cultureHierarchyUoW = cultureHierarchyUoW; m_staticTextUoW = staticTextUoW; }
public void StaticTextCreateUpdateTest() { var cultureUoW = new CultureUoW(m_sessionFactory); var dictionaryScopeUoW = new DictionaryScopeUoW(m_sessionFactory); var staticTextUoW = new StaticTextUoW(m_sessionFactory); cultureUoW.AddCulture("cs"); dictionaryScopeUoW.AddScope("dictionaryScope"); var time = DateTime.UtcNow; staticTextUoW.AddStaticText( "name", 0, "text", "cs", "dictionaryScope", "modificationUser", time ); var staticText = staticTextUoW.GetByNameAndCultureAndScope( "name", "cs", "dictionaryScope" ); Assert.AreEqual("name", staticText.Name); Assert.AreEqual("text", staticText.Text); staticTextUoW.UpdateStaticText( "name", "cs", "dictionaryScope", 0, "modifiedText", "modificationUser", time ); var staticTextReFetched = staticTextUoW.GetByNameAndCultureAndScope( "name", "cs", "dictionaryScope" ); Assert.AreEqual("modifiedText", staticTextReFetched.Text); }