Ejemplo n.º 1
0
        public void UpdateProductTest()
        {
            var        result    = UpdateProduct(_tf.Input("Pathway.wxs"), "1.13.4.4658", "BTE");
            const bool overwrite = true;

            File.Copy(result, _tf.Output("Pathway.wxs"), overwrite);
            File.Delete(result);
            XmlAssert.AreEqual(_tf.Expected("Pathway.wxs"), _tf.Output("Pathway.wxs"), "Pathway Product File mismatch on insert");
        }
Ejemplo n.º 2
0
        public void FixtureSetup()
        {
            xslParams = new Dictionary <string, object>();
            DateTime dateTime = new DateTime(2013, 8, 27);

            xslParams.Add("dateTime", dateTime.Date);
            xslParams.Add("user", "Tester");
            xslParams.Add("projName", "TestProj");
            xslParams.Add("stylesheet", "usfm");
            xslParams.Add("ws", "en");
            xslParams.Add("fontName", "Times");
            xslParams.Add("fontSize", "12");
            Param.LoadSettings();
            if (Common.CallerSetting != null)
            {
                try
                {
                    Common.CallerSetting.Dispose();
                }
                catch (Exception)
                {
                    // If there is an error disposing the old one, we just create the new one.
                }
            }
            Common.CallerSetting = new CallerSetting {
                SettingsFullPath = _tf.Input("TestDb.ssf")
            };
            ParatextPathwayLink converter = new ParatextPathwayLink("testDb", xslParams);

            encloseParasInSections = ParatextSupportExtensions.EncloseParasInSectionsXslt(converter);
        }
Ejemplo n.º 3
0
        public void AddChaptersTest()
        {
            const string fileName       = "DEU.SFM";
            string       inputFullName  = _testFiles.Input(fileName);
            string       outputFullName = _testFiles.SubOutput("SFM", fileName);

            File.Copy(inputFullName, outputFullName);
            PartialBooks.AddChapters(_testFiles.Output("SFM"));
            TextFileAssert.AreEqual(_testFiles.Expected(fileName), outputFullName);
        }
Ejemplo n.º 4
0
        public void GetProjectNameTest()
        {
            const string            fileName      = "1pe.xhtml";
            string                  inputFullName = _testFiles.Input(fileName);
            IPublicationInformation projInfo      = mocks.NewMock <IPublicationInformation>();

            Expect.Exactly(1).On(projInfo).GetProperty("DefaultXhtmlFileWithPath").Will(Return.Value(inputFullName));
            var result = GetProjectName(projInfo);

            Assert.AreEqual("TestFiles", result);
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
Ejemplo n.º 5
0
        public void ProcessTreeTest()
        {
            if (Common.IsUnixOS())
            {
                return;
            }
            ResetIds();
            var inputGuids = _tf.Input("FileLibrary.xml");

            LoadGuids(inputGuids);
            ApplicationFileName = "Application.wxs";
            DirectoryInfo directoryInfo = new DirectoryInfo(_tf.Input(@"output\Release"));

            foreach (DirectoryInfo directory in directoryInfo.GetDirectories())
            {
                ResetFileComponents();
                ProcessTree((XmlElement)XDoc.SelectSingleNode("//*[@Id='APPLICATIONFOLDER']"), directory.FullName);
                AddFeatures();
            }

            // Check File & Features Match
            var actualPath = _tf.Output("Application.wxs");
            var writer     = XmlTextWriter.Create(actualPath, new XmlWriterSettings {
                Indent = true, Encoding = Encoding.UTF8
            });

            XDoc.WriteTo(writer);
            writer.Close();
            XmlAssert.AreEqual(_tf.Expected("Application.wxs"), actualPath, "File Feature format changed");

            // Check no Guids created
            var actualGuids = _tf.Output("FileLibrary.xml");

            SaveGuids(actualGuids);
            XmlAssert.AreEqual(inputGuids, actualGuids, "Guids changed");
        }
Ejemplo n.º 6
0
		protected void SetUp()
		{
			Common.Testing = true;
			RegistryKey myKey = Registry.LocalMachine.OpenSubKey("Software\\Classes\\AutoIt3Script\\Shell\\Run\\Command", false);
			if (myKey != null)
			{
				_autoIt = myKey.GetValue("", "").ToString();
				if (_autoIt.EndsWith(@" ""%1"" %*"))
					_autoIt = _autoIt.Substring(0, _autoIt.Length - 8);
				else if (_autoIt.EndsWith(@" ""%1"""))
					_autoIt = _autoIt.Substring(0, _autoIt.Length - 5);     // Remove "%1" at end
			}
			_scriptPath = PathPart.Bin(Environment.CurrentDirectory, "/XhtmlExport");
			_tf = new TestFiles("XhtmlExport");
			var pwf = Common.PathCombine(Common.GetAllUserAppPath(), "SIL");
			var zf = new FastZip();
			zf.ExtractZip(_tf.Input("Pathway.zip"), pwf, ".*");
		}
Ejemplo n.º 7
0
        public void AddStyleTagTest()
        {
            PublicationInformation projInfo = new PublicationInformation();

            projInfo.DefaultXhtmlFileWithPath = _testFiles.Input("sena3-imba.xhtml");
            projInfo.DefaultCssFileWithPath   = _testFiles.Input("sena3-imba.css");
            var cssTree = new CssTree();

            CssClass = cssTree.CreateCssProperty(projInfo.DefaultCssFileWithPath, true);
            var ContentStyles = new DictionaryForMIDsStyle();
            var rec           = new DictionaryForMIDsRec {
                CssClass = CssClass, Styles = ContentStyles
            };
            var input = new DictionaryForMIDsInput(projInfo);
            var node  = input.SelectNodes("//*[@class = 'partofspeech']//text()")[0];

            rec.AddStyleTag(node);
            Assert.AreEqual(2, ContentStyles.NumStyles);
        }
Ejemplo n.º 8
0
        public void AddHeadwordTest()
        {
            PublicationInformation projInfo = new PublicationInformation();

            projInfo.DefaultXhtmlFileWithPath = _testFiles.Input("sena3-imba.xhtml");
            var input = new DictionaryForMIDsInput(projInfo);
            var sense = input.SelectNodes("//*[@class = 'entry']//*[@id]")[0];
            var rec   = new DictionaryForMIDsRec();

            rec.AddHeadword(sense);
            Assert.AreEqual("imba  ", rec.Rec);
        }
Ejemplo n.º 9
0
		public void XPathwayDictionarySettingTest()
		{
			_tf = new TestFiles("epubConvert");
			var pwf = Common.PathCombine(Common.GetAllUserAppPath(), "SIL");
			string pathwaySettingFolder = Common.PathCombine(pwf, "Pathway");
			Common.CopyFolderandSubFolder(pathwaySettingFolder, pathwaySettingFolder + "test", true);

			var zfile = new FastZip();
			zfile.ExtractZip(_tf.Input("Pathway.zip"), pwf, ".*");

			LoadParamValue("Dictionary");

			CleanOutputDirectory();
			string inputDataFolder = Common.PathCombine(_inputPath, "DictionarySettingTest");
			string outputDataFolder = Common.PathCombine(_outputPath, "DictionarySettingTest");
			Common.CopyFolderandSubFolder(inputDataFolder, outputDataFolder, true);

			const string xhtmlName = "main.xhtml";
			const string cssName = "main.css";
			var projInfo = new PublicationInformation();
			projInfo.ProjectInputType = "Dictionary";
			projInfo.ProjectPath = outputDataFolder;
			projInfo.DefaultXhtmlFileWithPath = Common.PathCombine(outputDataFolder, xhtmlName);
			projInfo.DefaultCssFileWithPath = Common.PathCombine(outputDataFolder, cssName);
			projInfo.ProjectName = "ABSDictionaryTestCase";
			Common.Testing = true;
			var target = new Exportepub();
			var actual = target.Export(projInfo);

			Common.CopyFolderandSubFolder(pathwaySettingFolder + "test", pathwaySettingFolder, true);


			Assert.IsTrue(actual);


			var result = projInfo.DefaultXhtmlFileWithPath.Replace(".xhtml", ".epub");
			var zf = new FastZip();
			zf.ExtractZip(result, FileOutput("main"), ".*");
			var zfExpected = new FastZip();
			result = Common.PathCombine(_expectedPath, "mainExpected.epub");
			zfExpected.ExtractZip(result, FileOutput("mainExpected"), ".*");

			string expectedFilesPath = FileOutput("mainExpected");
			expectedFilesPath = Common.PathCombine(expectedFilesPath, "OEBPS");
			string[] filesList = Directory.GetFiles(expectedFilesPath);
			foreach (var fileName in filesList)
			{
				var info = new FileInfo(fileName);
				if (info.Extension == ".xhtml" && !info.Name.Contains("File2Cpy"))
				{
					FileCompare("main/OEBPS/" + info.Name, "mainExpected/OEBPS/" + info.Name);
				}
			}
		}
Ejemplo n.º 10
0
        public void Fw83Test()
        {
            var projInfo = new PublicationInformation {
                DefaultXhtmlFileWithPath = _testFiles.Input("w1.xhtml")
            };
            var result = new DictionaryForMIDsInput(projInfo);

            Assert.IsTrue(result.Fw83());
        }