Пример #1
0
        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 DatabaseDictionaryService(
     LocalizationConfiguration configuration,
     CultureUoW cultureUoW,
     DictionaryScopeUoW dictionaryScopeUoW,
     ILogger <DatabaseDictionaryService> logger,
     IMemoryCache memoryCache
     ) : base(configuration, cultureUoW, dictionaryScopeUoW, logger, memoryCache)
 {
 }
 public DatabaseDynamicTextService(
     StaticTextUoW staticTextUoW,
     LocalizationConfiguration configuration,
     CultureUoW cultureUoW,
     DictionaryScopeUoW dictionaryScopeUoW,
     ILogger <DatabaseDynamicTextService> logger,
     IMemoryCache memoryCache
     ) : base(configuration, cultureUoW, dictionaryScopeUoW, logger, memoryCache)
 {
     m_staticTextUoW = staticTextUoW;
 }
Пример #4
0
 protected DatabaseServiceBase(
     LocalizationConfiguration configuration,
     CultureUoW cultureUoW,
     DictionaryScopeUoW dictionaryScopeUoW,
     ILogger <DatabaseServiceBase> logger,
     IMemoryCache memoryCache
     )
 {
     m_configuration      = configuration;
     m_cultureUoW         = cultureUoW;
     m_dictionaryScopeUoW = dictionaryScopeUoW;
     m_logger             = logger;
     m_memoryCache        = memoryCache;
 }
Пример #5
0
 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;
 }
Пример #6
0
 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;
 }
Пример #7
0
        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);
        }
        public void DictionaryCrTest()
        {
            var dictionaryScopeUoW = new DictionaryScopeUoW(m_sessionFactory);

            Assert.IsNull(dictionaryScopeUoW.GetScopeById(0));
            Assert.IsNull(dictionaryScopeUoW.GetScopeByName("not-exist"));

            dictionaryScopeUoW.AddScope("global");

            var allScopes = dictionaryScopeUoW.FindAllScopes();

            Assert.AreEqual(1, allScopes.Count);
            Assert.AreEqual("global", allScopes.First().Name);
            Assert.AreEqual("global", dictionaryScopeUoW.GetScopeById(1).Name);
            Assert.AreEqual("global", dictionaryScopeUoW.GetScopeByName("global").Name);
        }