public void QuitValidator_Invalid_Type() { // arrange // act var spreadSheet = new SpreadSheet(); var command = new QuitCommand(); var validator = new PerformSumValidator(); // assert Assert.ThrowsException <ArgumentException>(() => validator.Validate(spreadSheet, command)); }
public void PerformSumValidator_With_Negative_Y3_Throws_ValidationException() { // arrange // act var spreadSheet = new SpreadSheet(); spreadSheet.Cells.Add(new Cell(1, 1)); spreadSheet.Cells.Add(new Cell(2, 1)); spreadSheet.Cells.Add(new Cell(3, 1)); var command = new PerformSumCommand(1, 2, 2, 1, 3, -1); var validator = new PerformSumValidator(); // assert Assert.ThrowsException <ValidationException>(() => validator.Validate(spreadSheet, command)); }
private static ParseResult GetPerformSumParseResult(string[] commandArgs) { int x1 = int.Parse(commandArgs[0]); int y1 = int.Parse(commandArgs[1]); int x2 = int.Parse(commandArgs[2]); int y2 = int.Parse(commandArgs[3]); int x3 = int.Parse(commandArgs[4]); int y3 = int.Parse(commandArgs[5]); var command = new PerformSumCommand(x1, y1, x2, y2, x3, y3); var validator = new PerformSumValidator(); return(new ParseResult { Command = command, Validator = validator, }); }
public void PerformSum_Command() { // arrange var spreadSheet = new SpreadSheet(); int x1 = 1, y1 = 1, v1 = 1, x2 = 2, y2 = 1, v2 = 2, x3 = 3, y3 = 1, v3 = 3; spreadSheet.Cells.Add(new Cell(x1, y1, v1)); spreadSheet.Cells.Add(new Cell(x2, y2, v2)); spreadSheet.Cells.Add(new Cell(x3, y3, v3)); var command = new PerformSumCommand(x1, y1, x2, y2, x3, y3); var validator = new PerformSumValidator(); // act command.ExecuteCommand(spreadSheet, validator); // assert Assert.AreEqual(v1 + v2, spreadSheet[x3, y3].Value); }