public void FeatureSketchCreationBehavior() { /* * Problem description: * When a sketch contains duplicated points, the creation of a FeatureSketch * may delete those points. */ Sketch.Sketch sketch = Sketches.newValidSketch(); // Duplicate a point in the sketch Sketch.Shape shape = sketch.Shapes[0]; List <Sketch.Point> points = new List <Sketch.Point>(shape.Substrokes[0].Points); points.Add(points[points.Count - 1]); Sketch.Substroke substroke = new Sketch.Substroke(points); sketch.AddStroke(new Sketch.Stroke(substroke)); shape.AddSubstroke(substroke); Sketch.Sketch clone = sketch.Clone(); Assert.IsTrue(sketch.Equals(clone), "Sketch is not equal to its clone"); Featurefy.FeatureSketch featureSketch = newValidFeatureSketch(new Sketch.Project(sketch)); Assert.IsTrue(sketch.Equals(clone), "FeatureSketch creation modified original sketch"); }
public void TestXMLConversion() { const string filename = "tmp.xml"; Domain.ShapeType testType = Domain.LogicDomain.AND; Sketch.Sketch sketch1 = Sketches.newValidSketch(); foreach (Sketch.Shape shape in sketch1.Shapes) { shape.Type = testType; } ConverterXML.SaveToXML writer = new ConverterXML.SaveToXML(sketch1); writer.WriteXML(filename); ConverterXML.ReadXML reader = new ConverterXML.ReadXML(filename); Sketch.Sketch sketch2 = reader.Sketch; sketch2.CheckConsistency(); Assert.IsTrue(sketch1.Equals(sketch2), "Original sketch is not equal to the loaded sketch"); Assert.IsTrue(sketch2.Equals(sketch1), "Loaded sketch is not equal to the original"); foreach (Sketch.Shape shape in sketch2.Shapes) { Assert.AreEqual(testType, shape.Type, "Shape types are not preserved across save/load"); } }
public void TestXMLConversion() { const string filename = "tmp.xml"; RecognitionResult type = new RecognitionResult(LogicDomain.AND, 0.9, 0.33); Sketch.Project project1 = new Sketch.Project(Sketches.newValidSketch());; foreach (Sketch.Shape shape in project1.sketch.Shapes) { type.ApplyToShape(shape); } ConverterXML.SaveToXML writer = new ConverterXML.SaveToXML(project1); writer.WriteXML(filename); ConverterXML.ReadXML reader = new ConverterXML.ReadXML(filename); Sketch.Sketch sketch2 = reader.Sketch; sketch2.CheckConsistency(); Assert.IsTrue(project1.sketch.Equals(sketch2), "Original sketch is not equal to the loaded sketch"); Assert.IsTrue(sketch2.Equals(project1.sketch), "Loaded sketch is not equal to the original"); foreach (Sketch.Shape shape in sketch2.Shapes) { Assert.AreEqual(type.Type, shape.Type, "Shape types are not preserved across save/load"); Assert.IsTrue(Math.Abs(type.Confidence - shape.Probability) < 0.0001, "Shape confidences are not preserved across save/load"); Assert.IsTrue(Math.Abs(type.Orientation - shape.Orientation) < 0.0001, "Shape orientations are not preserved across save/load"); } }