public void ExecuteCommand_Canvas_Not_Exists() { string[] args = new string[] { "1", "2", "6", "2" }; CreateRectangle createRectangle = new CreateRectangle(null); var exception = Record.Exception(() => createRectangle.ExecuteCommand(args)); Assert.NotNull(exception); Assert.IsType <ArgumentException>(exception); Assert.Equal($"{Constants.Command_Canvas_Not_Exists}", exception.Message); }
public void ExecuteCommand_Invalid_Argument(string CommandName, string[] args) { CreateRectangle createRectangle = new CreateRectangle(_canvas.Object); var exception = Record.Exception(() => createRectangle.ExecuteCommand(args)); Assert.NotNull(exception); Assert.IsType <ArgumentException>(exception); Assert.Equal($"{Constants.Command_Expect_Four_Positive_Arguments}", exception.Message); Assert.Equal("R", CommandName); }
public void ExecuteCommand_Create_Rectangle_Success() { CreateCanvas createCanvas = new CreateCanvas(); string[] args1 = new string[] { "20", "4" }; var canvas = createCanvas.ExecuteCommand(args1); string[] args = new string[] { "14", "1", "18", "3" }; CreateRectangle createRectangle = new CreateRectangle(canvas); var result = createRectangle.ExecuteCommand(args); Assert.NotNull(result); for (int i = 14; i <= 18; i++) { Assert.Equal('x', canvas.Cells[i, 1]); Assert.Equal('x', canvas.Cells[i, 3]); } for (int i = 2; i < 3; i++) { Assert.Equal('x', canvas.Cells[14, i]); Assert.Equal('x', canvas.Cells[18, i]); } }