Example #1
0
        public void JudgesBookTest()
        {
            const string file = "JDG";

            string input = Common.PathCombine(_inputPath, file + ".usx");
            string output = Common.PathCombine(_outputPath, file + ".xml");
            string expected = Common.PathCombine(_expectedPath, file + ".xml");

            var inputTmpDir = Common.PathCombine(Path.GetTempPath(), Path.GetRandomFileName().Replace(".", "_"));
            Directory.CreateDirectory(inputTmpDir);
            string inputTmpDirFileName = string.Empty;
            inputTmpDirFileName = Common.PathCombine(inputTmpDir, "usx");
            Directory.CreateDirectory(inputTmpDirFileName);
            inputTmpDirFileName = Common.PathCombine(inputTmpDirFileName, Path.GetFileName(input));
            File.Copy(input, inputTmpDirFileName, true);

            ExportSword swordObj = new ExportSword();
            PublicationInformation projInfo = new PublicationInformation();
            projInfo.ProjectPath = inputTmpDir;
            projInfo.DefaultXhtmlFileWithPath = Common.PathCombine(inputTmpDir, "Test.xhtml");
            projInfo.ProjectFileWithPath = projInfo.ProjectPath;
            swordObj.OpenOutputDirectory = false;
            swordObj.Export(projInfo);

            string osisOutputFile = Common.PathCombine(inputTmpDir, "OSIS");
            var swordTmpDir = Common.PathCombine(Path.GetTempPath(), "Sword");
            osisOutputFile = Common.PathCombine(osisOutputFile, Path.GetFileName(output));
            if (File.Exists(osisOutputFile))
            {
                File.Copy(osisOutputFile, output, true);
            }

            if (Directory.Exists(swordTmpDir))
            {
                swordObj.CopySwordCreatorFolderToTemp(swordTmpDir, Common.PathCombine(_outputPath, file), null);
            }
            string swordOutputPath = Common.PathCombine(_outputPath, file);
            Common.CleanupExportFolder(Common.PathCombine(swordOutputPath, file + ".xml"), ".exe,.dll", string.Empty, string.Empty);

            if (Directory.Exists(inputTmpDir))
            {
                DirectoryInfo di = new DirectoryInfo(inputTmpDir);
                Common.CleanDirectory(di);
            }

            if (Directory.Exists(swordTmpDir))
            {
                DirectoryInfo di = new DirectoryInfo(swordTmpDir);
                Common.CleanDirectory(di);
            }

            FileAssert.AreEqual(expected, output, file + " test fails");
        }
Example #2
0
        public void ExportSwordTest()
        {
            string inputSourceDirectory = FileInput("SwordExportTest");
            string outputDirectory = FileOutput("SwordExportTest");
            if (Directory.Exists(outputDirectory))
            {
                Directory.Delete(outputDirectory, true);
            }
            FolderTree.Copy(inputSourceDirectory, outputDirectory);
            Param.LoadSettings();
            _projInfo.ProjectPath = outputDirectory;
            _projInfo.ProjectInputType = "Scripture";
            _projInfo.DefaultXhtmlFileWithPath = Common.PathCombine(outputDirectory, "A4_Cols_ApplicationStyles.xhtml");
            _projInfo.DefaultCssFileWithPath = Common.PathCombine(outputDirectory, "A4_Cols_ApplicationStyles.css");

            var target = new ExportSword();
            const bool expectedResult = true;
            bool actual = target.Export(_projInfo);
            Assert.AreEqual(expectedResult, actual);
        }
Example #3
0
        private void btnSword_Click(object sender, EventArgs e)
        {

            if (!File.Exists(txtInputPath.Text))
            {
                MessageBox.Show("Please select the valid usx file");
                return;
            }

            if (Path.GetExtension(txtInputPath.Text) != ".usx")
            {
                MessageBox.Show("Please select the valid usx file");
                return;
            }

            string directoryName = string.Empty;
            directoryName = Path.GetFileName(Path.GetDirectoryName(txtInputPath.Text));
            if (directoryName.ToLower() != "usx")
            {
                MessageBox.Show("Folder name should be [usx]");
                return;
            }


            string xhtmlFile = string.Empty;
            if (File.Exists(txtInputPath.Text))
            {
                xhtmlFile = Path.GetDirectoryName(txtInputPath.Text);
                xhtmlFile = Path.GetDirectoryName(xhtmlFile);
                xhtmlFile = Common.PathCombine(xhtmlFile, "Test.xhtml");
            }

            ExportSword swordObj = new ExportSword();
            PublicationInformation projInfo = new PublicationInformation();
            projInfo.ProjectPath = Path.GetDirectoryName(xhtmlFile);
            projInfo.DefaultXhtmlFileWithPath = xhtmlFile;
            projInfo.ProjectFileWithPath = projInfo.ProjectPath;
            swordObj.Export(projInfo);
            MessageBox.Show("Done");
        }