public void Execute(string commandName, params string[] parameters) { var command = DrawingCommandFactory.CreateCommand(commandName, _canvas); command.Draw(parameters); if (commandName == CommandNames.CANVAS) { _canvas = ((CanvasDrawingCommand)command).Canvas; } _drawingRender.Render(_canvas); }
public void ShouldCreateBucketFillCommand() { var command = DrawingCommandFactory.CreateCommand(CommandNames.BUCKET_FILL, new Drawing.Canvas(1, 2)); Assert.IsInstanceOf <BucketFillDrawingCommand>(command); }
public void ShouldThrowExceptionWhenCreateBucketFillCommandWithoutCanvas() { Assert.That(() => { DrawingCommandFactory.CreateCommand(CommandNames.BUCKET_FILL); }, Throws.InstanceOf <ArgumentException>()); }
public void ShouldThrowExceptionWhenCreateDrawRetangleCommandWithoutCanvas() { Assert.That(() => { DrawingCommandFactory.CreateCommand(CommandNames.RECTANGLE); }, Throws.InstanceOf <ArgumentException>()); }
public void ShouldCreateDrawRetangleCommand() { var command = DrawingCommandFactory.CreateCommand(CommandNames.RECTANGLE, new Drawing.Canvas(1, 2)); Assert.IsInstanceOf <RectangleDrawingCommand>(command); }
public void ShouldCreateDrawLineCommand() { var command = DrawingCommandFactory.CreateCommand(CommandNames.LINE, new Drawing.Canvas(1, 2)); Assert.IsInstanceOf <LineDrawingCommand>(command); }
public void ShouldCreateDrawCanvasCommand() { var command = DrawingCommandFactory.CreateCommand(CommandNames.CANVAS); Assert.IsInstanceOf <CanvasDrawingCommand>(command); }
public void ShouldThrowExceptionWhenCommandNameNotExists() { Assert.That(() => { DrawingCommandFactory.CreateCommand("invalid command"); }, Throws.InstanceOf <NotSupportedException>()); }