Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }