Exemplo n.º 1
0
        public void VerifyMissingTranslationsTest()
        {
            var f = new MuiDBFile("..\\..\\TestData\\MissingTranslations.xml");

            bool exceptionWasThrown = false;

            try
            {
                f.Validate();
            }
            catch (MissingTranslationsException e)
            {
                exceptionWasThrown = true;
                var expected = new List <string>()
                {
                    "item1:de", "item2:en"
                };
                e.Items.ShouldBeEquivalentTo(expected, "missing items should match expected");
            }
            catch (Exception)
            {
            }
            finally
            {
                exceptionWasThrown.Should().BeTrue("Verify must throw MissingTranslationsException on missing translations");
            }
        }
Exemplo n.º 2
0
        public void ImportExistingLanguageFromResxTest()
        {
            var f = new MuiDBFile("..\\..\\TestData\\Sample.xml");

            f.GetLanguages().Should().Contain("de");
            f.ImportResX("..\\..\\TestData\\Sample.de.resx", "de");
            f.GetLanguages().Should().Contain("de");
        }
Exemplo n.º 3
0
        public void ImportNewItemWithInvalidState()
        {
            var f = new MuiDBFile("new", MuiDBFile.OpenMode.CreateIfMissing);

            var id    = "someRandomNewId";
            var state = "some invalid state";
            var lang  = "xx";

            f.Items.Should().NotContain((i) => i.Id == id);
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => f.AddOrUpdateString(id, lang, "yy", state, null));
        }
Exemplo n.º 4
0
        public void ExportInvalidLanguageTest()
        {
            var f = new MuiDBFile("..\\..\\TestData\\Sample.xml");

            f.GetLanguages().Should().NotContain("fr");

            try
            {
                f.ExportResX("sdfs", "fr");
                Assert.Fail("Export of unknown language must lead to ArgumentException");
            }
            catch (ArgumentException e)
            {
                e.Message.ShouldBeEquivalentTo("'fr' is not a configured language.");
            }
        }
Exemplo n.º 5
0
        public void ImportNewItemTest()
        {
            var f = new MuiDBFile("new", MuiDBFile.OpenMode.CreateIfMissing);

            var id    = "someRandomNewId";
            var lang  = "de";
            var state = "new";
            var value = "Ein Ring, sie alle zu kechten, sie alle zu finden.";

            f.Items.Should().NotContain((i) => i.Id == id);
            f.GetLanguages().Should().NotContain(lang);
            f.AddOrUpdateString(id, lang, value, state, null);
            f.GetLanguages().Should().Contain(lang);
            f.Items.Should().Contain((i) => i.Id == id);
            var item = f.Items.First((i) => i.Id == id);

            item.Texts.Should().ContainKey(lang);
            item.Texts[lang].State.Should().Be(state);
            item.Texts[lang].Value.Should().Be(value);
            item.Comments.Should().BeEmpty();

            // import second language
            var lang2   = "en";
            var state2  = "translated";
            var value2  = "One Ring to rule them all, One Ring to find them.";
            var comment = "This is a test";

            f.AddOrUpdateString(id, lang2, value2, state2, comment);
            f.GetLanguages().Should().Contain(lang2);
            f.Items.Should().Contain((i) => i.Id == id);
            item = f.Items.First((i) => i.Id == id);
            item.Texts.Should().ContainKey(lang2);
            item.Texts[lang2].State.Should().Be(state2);
            item.Texts[lang2].Value.Should().Be(value2);
            item.Comments.Should().Contain(MuiDBFile.NeutralLanguage, comment);

            // check if document is compliant with schema
            // (comment node must be first child element of the item etc.)
            f.Validate();
        }
Exemplo n.º 6
0
        public void ReadProjectTitle()
        {
            var f = new MuiDBFile("..\\..\\TestData\\Sample.xml");

            f.ProjectTitle.Should().Be("test sample");
        }