public CanvasDrawerDrawingState(CanvasDrawer canvasDrawerData, Point currentDrawingShapeDrawingStartingPointData)
 {
     if (canvasDrawerData == null)
     {
         throw new ArgumentNullException(Definitions.ERROR_CANVAS_DRAWER_IS_NULL);
     }
     if (currentDrawingShapeDrawingStartingPointData == null)
     {
         throw new ArgumentNullException(ERROR_CURRENT_DRAWING_SHAPE_DRAWING_STARTING_POINT_IS_NULL);
     }
     _canvasDrawer = canvasDrawerData;
     _currentDrawingShapeDrawingStartingPoint = currentDrawingShapeDrawingStartingPointData;
     _currentDrawingShapeHintShapeDrawer      = ShapeDrawerFactory.CreateShapeDrawer(_currentDrawingShapeDrawingStartingPoint, _currentDrawingShapeDrawingStartingPoint, _canvasDrawer.CurrentShapeDrawerType);
 }
        public void TestCreateShapeDrawer()
        {
            const string SHAPE_DRAWER_MEMBER_VARIABLE_NAME_DRAWING_STARTING_POINT = "_drawingStartingPoint";
            const string SHAPE_DRAWER_MEMBER_VARIABLE_NAME_DRAWING_ENDING_POINT   = "_drawingEndingPoint";

            Assert.ThrowsException <ArgumentException>(() => ShapeDrawerFactory.CreateShapeDrawer(new Point(), new Point(), ShapeDrawerType.None));
            Assert.ThrowsException <ArgumentException>(() => ShapeDrawerFactory.CreateShapeDrawer(new Point(), new Point(), ( ShapeDrawerType )(-1)));
            Assert.ThrowsException <ArgumentException>(() => ShapeDrawerFactory.CreateShapeDrawer(new Point(), new Point(), ( ShapeDrawerType )3));
            var drawingStartingPoint = new Point();
            var drawingEndingPoint   = new Point();
            // Create line drawer.
            ShapeDrawer expectedShapeDrawer = ShapeDrawerFactory.CreateShapeDrawer(drawingStartingPoint, drawingEndingPoint, ShapeDrawerType.Line);
            var         target = new PrivateObject(expectedShapeDrawer);

            Assert.AreSame(target.GetFieldOrProperty(SHAPE_DRAWER_MEMBER_VARIABLE_NAME_DRAWING_STARTING_POINT), drawingStartingPoint);
            Assert.AreSame(target.GetFieldOrProperty(SHAPE_DRAWER_MEMBER_VARIABLE_NAME_DRAWING_ENDING_POINT), drawingEndingPoint);
            Assert.IsInstanceOfType(expectedShapeDrawer, typeof(LineDrawer));
            // Create rectangle drawer.
            expectedShapeDrawer = ShapeDrawerFactory.CreateShapeDrawer(drawingStartingPoint, drawingEndingPoint, ShapeDrawerType.Rectangle);
            target = new PrivateObject(expectedShapeDrawer);
            Assert.AreSame(target.GetFieldOrProperty(SHAPE_DRAWER_MEMBER_VARIABLE_NAME_DRAWING_STARTING_POINT), drawingStartingPoint);
            Assert.AreSame(target.GetFieldOrProperty(SHAPE_DRAWER_MEMBER_VARIABLE_NAME_DRAWING_ENDING_POINT), drawingEndingPoint);
            Assert.IsInstanceOfType(expectedShapeDrawer, typeof(RectangleDrawer));
        }