// Should create rectangle from [100,200] to [40,40] public void RectangleTest() { ITool CurrentTool = new RectangleTool(); // user clicked on point [100,200] CurrentTool.GetShape(new CanvasEventArgs(new Point(100, 200), MouseState.DOWN), style); // user hold mouse and move, this should update current rectangle on canvas CurrentTool.GetShape(new CanvasEventArgs(new Point(80, 170), MouseState.MOVE), style); CurrentTool.GetShape(new CanvasEventArgs(new Point(60, 100), MouseState.MOVE), style); // user release mouse, at this point rectangle shouldn't be modified by any mouse action Rectangle r = (Rectangle)CurrentTool.GetShape(new CanvasEventArgs(new Point(40, 40), MouseState.UP), style).TikzShape.Shape; Assert.AreEqual(60, r.Width); Assert.AreEqual(160, r.Height); }
public void DrawShapeGenerateJsonFromItAndConvertItBackToShape() { ITool CurrentTool = new RectangleTool(); CurrentTool.GetShape(new CanvasEventArgs(new Point(100, 200), MouseState.DOWN), style); CurrentTool.GetShape(new CanvasEventArgs(new Point(80, 170), MouseState.MOVE), style); CurrentTool.GetShape(new CanvasEventArgs(new Point(60, 100), MouseState.MOVE), style); TikzShape[] shapes = new TikzShape[] { CurrentTool.GetShape(new CanvasEventArgs(new Point(40, 40), MouseState.UP), style).TikzShape }; JsonFormatGenerator jsonGen = new JsonFormatGenerator(); String jsonTikz = jsonGen.ConvertMany(shapes); Assert.IsTrue(new JsonFormatLoader().ConvertMany(jsonTikz).ToList().Single(shape => shape is TikzRectangle) != null); }