Beispiel #1
0
        public void ExportResXTest()
        {
            var f = new MuiDB.MuiDBFile("..\\..\\TestData\\Sample.xml");

            f.TargetFiles.Should().NotBeEmpty("the sample has target files defined for export");
            f.TargetFiles.Count().ShouldBeEquivalentTo(3, "there are three target files defined in the sample");

            var tempFile_en = System.IO.Path.GetTempFileName();
            var tempFile_de = System.IO.Path.GetTempFileName();

            try
            {
                f.ExportResX(tempFile_en, "en", MuiDBFile.SaveOptions.SortEntries);
                f.ExportResX(tempFile_de, "de");

                var content_en  = System.IO.File.ReadAllLines(tempFile_en);
                var content_de  = System.IO.File.ReadAllLines(tempFile_de);
                var expected_en = System.IO.File.ReadAllLines("..\\..\\TestData\\Sample.en.resx");
                var expected_de = System.IO.File.ReadAllLines("..\\..\\TestData\\Sample.de.resx");

                for (int i = 0; i < content_en.Length; ++i)
                {
                    content_en[i].Should().Be(expected_en[i], "the result must be sorted and contain the right values");
                }

                content_de.ShouldBeEquivalentTo(expected_de, "Result must be sorted and contain the right values");
            }
            finally
            {
                System.IO.File.Delete(tempFile_en);
                System.IO.File.Delete(tempFile_de);
            }
        }
Beispiel #2
0
        public void TextsAreNotEmpty()
        {
            var f = new MuiDB.MuiDBFile("..\\..\\TestData\\Sample.xml");

            foreach (var item in f.Items)
            {
                item.Texts.Should().NotBeEmpty("the sample data has translations defined");
            }
        }
Beispiel #3
0
        public void LoadFileTest()
        {
            var filename = Guid.NewGuid().ToString();
            var f        = new MuiDB.MuiDBFile(filename, MuiDBFile.OpenMode.CreateIfMissing);

            f.Filename.Should().BeSameAs(filename);
            f.TargetFiles.Should().BeEmpty();
            f.Items.Should().BeEmpty();
            f.GetDocumentCopy().ToString(System.Xml.Linq.SaveOptions.DisableFormatting)
            .Should().BeEquivalentTo(MuiDB.MuiDBFile.EmptyDocument, "file should be created if it does not exist and therefore match match default empty file");
        }
Beispiel #4
0
        public void SaveExistingTest()
        {
            var f        = new MuiDB.MuiDBFile("..\\..\\TestData\\Sample.xml");
            var tempFile = System.IO.Path.GetTempFileName();

            try
            {
                f.Save(tempFile);
                var doc = XDocument.Load(tempFile);
                doc.Should().BeEquivalentTo(f.GetDocumentCopy(), "saved file should have same content as document in memory");
            }
            finally
            {
                System.IO.File.Delete(tempFile);
            }
        }
Beispiel #5
0
        public void SaveNewTest()
        {
            var filename = Guid.NewGuid().ToString();

            Assert.IsFalse(System.IO.File.Exists(filename), "new file must not exist before save");
            var f = new MuiDB.MuiDBFile(filename, MuiDBFile.OpenMode.CreateIfMissing);

            try
            {
                f.Save();
                Assert.IsTrue(System.IO.File.Exists(filename), "new file must exist after save");
                var doc = XDocument.Load(filename);
                doc.Should().BeEquivalentTo(f.GetDocumentCopy(), "saved file should have same content as document in memory");
            }
            finally
            {
                System.IO.File.Delete(filename);
            }
        }
Beispiel #6
0
        public void ItemsAreNotEmpty()
        {
            var f = new MuiDB.MuiDBFile("..\\..\\TestData\\Sample.xml");

            f.Items.Should().NotBeEmpty("the sample must have translation items!");
        }
Beispiel #7
0
        public void SampleSchemaTest()
        {
            var f = new MuiDB.MuiDBFile("..\\..\\TestData\\Sample.xml");

            f.Validate();
        }