public void CreateCatalogueWithNoAcronym_CrashesDITAExtractor() { var testDir = _directoryHelper.Directory; try { //create a new Catalogue in the test datbaase that doesnt have a acronym (should crash Dita Extractor) Catalogue myNewCatalogue = new Catalogue(CatalogueRepository, "UnitTestCatalogue"); myNewCatalogue.Acronym = ""; myNewCatalogue.SaveToDatabase(); try { DitaCatalogueExtractor extractor = new DitaCatalogueExtractor(CatalogueRepository, testDir); var ex = Assert.Throws <Exception>(() => extractor.Extract(new ThrowImmediatelyDataLoadEventListener())); Assert.AreEqual("Dita Extraction requires that each catalogue have a unique Acronym, the catalogue UnitTestCatalogue is missing an Acronym", ex.Message); } finally { myNewCatalogue.DeleteInDatabase(); } } finally { foreach (var file in testDir.GetFiles()) { file.Delete(); } } }
private void btnExtract_Click(object sender, EventArgs e) { try { DirectoryInfo outputPath = new DirectoryInfo(tbExtractionDirectory.Text); if (outputPath.GetFiles("*.dita*").Any()) { if (Activator.YesNo("There are files already in this directory, do you want to delete them?", "Clear Directory?")) { foreach (FileInfo file in outputPath.GetFiles("*.dita*")) { file.Delete(); } } } DitaCatalogueExtractor extractor = new DitaCatalogueExtractor(Activator.RepositoryLocator.CatalogueRepository, outputPath); extractor.Extract(progressBarsUI1); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnCheck_Click(object sender, EventArgs e) { var popup = new PopupChecksUI("Checking Dita extraction", false); DitaCatalogueExtractor extractor = new DitaCatalogueExtractor(Activator.RepositoryLocator.CatalogueRepository, null); popup.StartChecking(extractor); }
public void Predict(string name, string predictedAcronym) { DitaCatalogueExtractor extractor = new DitaCatalogueExtractor(CatalogueRepository, null); string suggestion = extractor.GetAcronymSuggestionFromCatalogueName(name); Assert.AreEqual(predictedAcronym, suggestion); }
public void DitaExtractorConstructor_ExtractTestCatalogue_FilesExist() { var testDir = _directoryHelper.Directory; //get rid of any old copies lying around Catalogue oldCatalogueVersion = CatalogueRepository.GetAllObjects <Catalogue>().SingleOrDefault(c => c.Name.Equals("DitaExtractorConstructor_ExtractTestCatalogue_FilesExist")); if (oldCatalogueVersion != null) { oldCatalogueVersion.DeleteInDatabase(); } Catalogue ditaTestCatalogue = new Catalogue(CatalogueRepository, "DitaExtractorConstructor_ExtractTestCatalogue_FilesExist");//name of Catalogue ditaTestCatalogue.Acronym = "DITA_TEST"; ditaTestCatalogue.Description = "Test catalogue for the unit test DitaExtractorConstructor_ExtractTestCatalogue_FilesExist in file " + typeof(DitaExtractorTests).FullName + ".cs"; ditaTestCatalogue.SaveToDatabase(); try { DitaCatalogueExtractor extractor = new DitaCatalogueExtractor(CatalogueRepository, testDir); extractor.Extract(new ThrowImmediatelyDataLoadEventListener()); //make sure the root mapping files exist for navigating around Assert.IsTrue(File.Exists(Path.Combine(testDir.FullName, "hic_data_catalogue.ditamap"))); Assert.IsTrue(File.Exists(Path.Combine(testDir.FullName, "introduction.dita"))); Assert.IsTrue(File.Exists(Path.Combine(testDir.FullName, "dataset.dita"))); //make sure the catalogue we created is there FileInfo ditaCatalogueAsDotDitaFile = new FileInfo(Path.Combine(testDir.FullName, "ditaextractorconstructor_extracttestcatalogue_filesexist.dita"));//name of Dita file (for the Catalogue we just created) Assert.IsTrue(ditaCatalogueAsDotDitaFile.Exists); Assert.IsTrue(File.ReadAllText(ditaCatalogueAsDotDitaFile.FullName).Contains(ditaTestCatalogue.Description)); } finally { ditaTestCatalogue.DeleteInDatabase(); foreach (var file in testDir.GetFiles()) { file.Delete(); } } }