Ejemplo n.º 1
0
        public void TestStandardMerge()
        {
            Shape shape1 = Shapes.newValidShape();
            Shape shape2 = Shapes.newValidShape();
            Shape shape3 = Shapes.newValidShape();

            Sketch.Sketch sketch = new Sketch.Sketch();

            sketch.CheckConsistency();

            sketch.AddShape(shape1);
            sketch.AddShape(shape2);
            sketch.AddShape(shape3);

            sketch.connectShapes(shape1, shape3);
            sketch.connectShapes(shape2, shape3);

            Assert.IsTrue(sketch.AreConnected(shape1, shape3), "Shape 1 is not connected to shape 3");
            Assert.IsTrue(sketch.AreConnected(shape2, shape3), "Shape 2 is not connected to shape 3");

            sketch.CheckConsistency();

            Assert.IsTrue(sketch.containsShape(shape1), "Sketch does not contain shape 1");
            Assert.IsTrue(sketch.containsShape(shape2), "Sketch does not contain shape 2");

            sketch.mergeShapes(shape1, shape2);

            Assert.IsTrue(sketch.AreConnected(shape1, shape3), "Shape 1 is not connected to shape 3 (after merge)");
            Assert.IsFalse(sketch.AreConnected(shape1, shape1), "Shape 1 is connected to itself (after merge)");
            Assert.IsFalse(sketch.AreConnected(shape1, shape2), "Shape 1 is connected to shape 2 (after merge)");

            Assert.IsTrue(sketch.containsShape(shape1), "Sketch does not contain shape 1 (after merge)");
            Assert.IsFalse(sketch.containsShape(shape2), "Sketch contains shape 2 (after merge)");
        }