public void ShouldAnalyzeSimpleSchemaWithComplexTypes() { // Setup var results = XMLSchemaReader.Read(TestUtils.PathToTestResource(@"simpleSchema_withComplexTypes.xsd")); // Events // Assertion and Verification foreach (var result in results) { Console.WriteLine(result.Caption + ": " + result.Count); } }
public void ShouldAnalyzeSimpleSchema() { // Setup var results = XMLSchemaReader.Read(TestUtils.PathToTestResource(@"simpleSchema.xsd")); // Events // Assertion and Verification foreach (var result in results) { if (result.Caption.Equals("Attribute")) { Assert.That(result.Count.Equals(1)); } if (result.Caption.Equals("Element")) { Assert.That(result.Count.Equals(12)); } } }
private bool Analyze(string file, int chart) { SchemaAnalyzerResults results; try { results = XMLSchemaReader.Read(file); } catch (FileNotFoundException fnfe) { MessageBox.Show("The given file could not be opened!\n" + fnfe.Message, Title, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } catch (DirectoryNotFoundException dnfe) { MessageBox.Show("The given path could not be opened!\n" + dnfe.Message, Title, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } catch (XmlException xe) { MessageBox.Show("The given file could not be read!\n" + xe.Message, Title, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } catch (XmlSchemaException xse) { MessageBox.Show("The given file could not be read!\n" + xse.Message, Title, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } started = true; (chart == 1 ? chart1 : chart2).Series[0].DataPoints.Clear(); double curPos = 0.0; double deltaPos = 1 / ((double)results.Count - 1); foreach (SchemaAnalyzerResult dataset in results) { Color curColor = GetComplexityColor(curPos > 1 ? 1 : curPos); var item = new DataPoint { YValue = dataset.Count, AxisXLabel = dataset.Caption, Color = new SolidColorBrush(Color.FromRgb(curColor.R, curColor.G, curColor.B)) }; (chart == 1 ? chart1 : chart2).Series[0].DataPoints.Add(item); curPos += deltaPos; } //sort results for comparison view results.Sort(new SchemaAnalyzerResultComparerByName()); chart3.Series[chart - 1].DataPoints.Clear(); foreach (SchemaAnalyzerResult dataset in results) { var item2 = new DataPoint { YValue = dataset.Count, AxisXLabel = dataset.Caption }; chart3.Series[chart - 1].DataPoints.Add(item2); } chart3.Series[chart - 1].LegendText = file.Substring(file.LastIndexOf("\\") + 1); //afterwards restore original sort results.Sort(new SchemaAnalyzerResultComparerByValue()); (chart == 1 ? tab1 : tab2).Header = file.Substring(file.LastIndexOf("\\") + 1); (chart == 1 ? complexity1 : complexity2).Fill = new SolidColorBrush(GetComplexityColor(results.Complexity)); (chart == 1 ? complexity1 : complexity2).Visibility = Visibility.Visible; (chart == 1 ? complexityMover1 : complexityMover2).Width = (int)(results.Complexity * canvas1.ActualWidth); if (chart == 1) { results1 = results; } else { results2 = results; } return(true); }