public override void Execute(object parameter) { var g = new SampleDataGenerator(); string d = g.Translate(ActiveDiagramView.Diagram as PSMDiagram); SampleDocumentWindow.Show(MainWindow.dockManager, d, ActiveDiagramView.Diagram as PSMDiagram, g.Log); }
public void TestSampleGenerator() { Project project = TestUtils.CreateSampleProject(); SampleDataGenerator generator = new SampleDataGenerator(); PSMSchema psmSchema = project.SingleVersion.PSMSchemas[0]; XDocument xmlDocument = generator.Translate(psmSchema); xmlDocument.Save("TestSampleGenerator.xml"); }
private void CreateSampleNewDocument() { SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(); sampleDataGenerator.GenerateComments = false; XDocument sampleDoc = sampleDataGenerator.Translate(schemaVersion2); tbNewDoc.Text = XDocumentToString(sampleDoc); UpdateFolding(); }
private void CreateSampleNewDocument() { SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(); sampleDataGenerator.GenerateComments = false; string sampleDoc = sampleDataGenerator.Translate(diagramNewVersion); tbNewDoc.Text = sampleDoc; UpdateFolding(); }
private void CreateSampleDocument() { SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(); sampleDataGenerator.GenerateComments = false; string sampleDoc = sampleDataGenerator.Translate(diagramOldVersion); tbOldDoc.Text = sampleDoc; SaveOutput(sampleDoc); UpdateFolding(); }
private void GenerateAnotherFile(IFilePresenterTab filetab) { SampleDataGenerator g = new SampleDataGenerator(); if (ScopeObject != null) { g.RootForGeneration = (PSMAssociationMember)ScopeObject; } XDocument xmlDocument = g.Translate(filetab.ValidationSchema); filetab.SetDocumentText(xmlDocument.ToString()); }
private void CreateSampleDocument() { SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(); sampleDataGenerator.GenerateComments = false; XDocument sampleDoc = sampleDataGenerator.Translate(schemaVersion1, bSchemaAware.IsChecked == true ? "LastSchema.xsd" : null); string documentString = XDocumentToString(sampleDoc); tbOldDoc.Text = documentString; SaveOutput(documentString); UpdateFolding(); }
public override void Execute(object parameter) { SampleDataGenerator g = new SampleDataGenerator(); g.MinimalTree = true; g.EmptyValues = true; g.UseAttributesDefaultValues = false; if (ScopeObject != null) { g.RootForGeneration = (PSMAssociationMember)ScopeObject; } XDocument xmlDocument = g.Translate((PSMSchema)Current.ActiveDiagram.Schema); FilePresenterButtonInfo[] additionalButtonsInfo = new [] { new FilePresenterButtonInfo() { Text = "Generate another file", Icon = ExolutioResourceNames.GetResourceImageSource(ExolutioResourceNames.xmlIcon), UpdateFileContentAction = GenerateAnotherFile } }; Current.MainWindow.FilePresenter.DisplayFile(xmlDocument, EDisplayedFileType.XML, Current.ActiveDiagram.Caption + "_sample.xml", g.Log, (PSMSchema)Current.ActiveDiagram.Schema, null, additionalButtonsInfo); }
public void TestValidationOnRandomFiles(string filename) { Console.WriteLine("Testing file {0}.", filename); //string filename = "Attributes\\Attributes5.XCase"; XmlDeserializatorVersions deserializator = new XmlDeserializatorVersions(); VersionManager versionManager = deserializator.RestoreVersionedProject(TEST_BASE_DIR + filename); Assert.IsTrue(versionManager != null && versionManager.VersionedProjects.Count == 2 && versionManager.Versions.Count == 2); Version oldVersion = versionManager.Versions[0]; Version newVersion = versionManager.Versions[1]; PSMDiagram diagramNewVersion = versionManager.VersionedProjects[newVersion].PSMDiagrams[0]; PSMDiagram diagramOldVersion = versionManager.VersionedProjects[oldVersion].PSMDiagrams[0]; ChangesDetector detector = new ChangesDetector(); List <EvolutionChange> evolutionChanges = detector.Translate(diagramOldVersion, diagramNewVersion); XsltTemplateGenerator xsltGenerator = new XsltTemplateGenerator(diagramNewVersion); string xsltTransformation = xsltGenerator.Generate(evolutionChanges, oldVersion, newVersion); SampleDataGenerator g = new SampleDataGenerator(); DocumentValidator validator = new DocumentValidator { SilentMode = true }; string outputFileDir = TEST_BASE_DIR + Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + "-error"; int fails = 0; for (int i = 0; i < RANDOM_FILE_COUNT; i++) { string input = g.Translate(diagramOldVersion); if (!validator.ValidateDocument(diagramOldVersion, input)) { if (!Directory.Exists(outputFileDir)) { Directory.CreateDirectory(outputFileDir); } File.WriteAllText(string.Format("{0}\\i{1}.xml", outputFileDir, i), input); Console.WriteLine("Input document INVALID: " + validator.ErrorMessage); fails++; continue; } string result = XsltProcessing.Transform(input, xsltTransformation, TEST_BASE_DIR); if (!validator.ValidateDocument(diagramNewVersion, result)) { if (!Directory.Exists(outputFileDir)) { Directory.CreateDirectory(outputFileDir); } File.WriteAllText(string.Format("{0}\\i{1}.xml", outputFileDir, i), input); File.WriteAllText(string.Format("{0}\\o{1}.xml", outputFileDir, i), result); Console.WriteLine("Result document INVALID: " + validator.ErrorMessage); fails++; continue; } Console.WriteLine("Test passed on file {0}/{1}", i, RANDOM_FILE_COUNT); } Console.WriteLine("Altogether tested on {0} random files. ", RANDOM_FILE_COUNT); if (fails != 0) { Console.WriteLine("{0} out of {1} files failed to pass. ", fails, RANDOM_FILE_COUNT); Assert.Fail("{0} out of {1} files failed to pass. ", fails, RANDOM_FILE_COUNT); } else { Console.WriteLine("All {0} files passed. ", RANDOM_FILE_COUNT); } }