public void TestFillCompleteCanvasWhenEmpty(string Command) { bucketFillCommandHandler.ProcessCommand(Command); var filledCanvasString = MatrixToStringConverter.Convert(new char[6, 5] { { '-', '-', '-', '-', '-' }, { '|', 'o', 'o', 'o', '|' }, { '|', 'o', 'o', 'o', '|' }, { '|', 'o', 'o', 'o', '|' }, { '|', 'o', 'o', 'o', '|' }, { '-', '-', '-', '-', '-' } }); Assert.AreEqual(stringWriter.ToString(), emptyCanvasString + filledCanvasString); }
public void TestValidLineAndRectangleCommand(string lineCommand, string rectangleCommand) { lineCommandHandler.ProcessCommand(lineCommand); var lineOnCanvasString = MatrixToStringConverter.Convert(new char[6, 5] { { '-', '-', '-', '-', '-' }, { '|', ' ', ' ', 'x', '|' }, { '|', ' ', ' ', 'x', '|' }, { '|', ' ', ' ', 'x', '|' }, { '|', ' ', ' ', 'x', '|' }, { '-', '-', '-', '-', '-' }, }); Assert.AreEqual(stringWriter.ToString(), emptyCanvasString + lineOnCanvasString); rectangleCommandHandler.ProcessCommand(rectangleCommand); var lineAndRectangleOnCanvasString = MatrixToStringConverter.Convert(new char[6, 5] { { '-', '-', '-', '-', '-' }, { '|', 'x', 'x', 'x', '|' }, { '|', 'x', 'x', 'x', '|' }, { '|', ' ', ' ', 'x', '|' }, { '|', ' ', ' ', 'x', '|' }, { '-', '-', '-', '-', '-' }, }); Assert.AreEqual(stringWriter.ToString(), emptyCanvasString + lineOnCanvasString + lineAndRectangleOnCanvasString); }
public void TestDrawRectangleAndBucketFillCommand(string rectangleCommand, string fillCommand) { Assert.NotNull(stringWriter.ToString()); Assert.AreEqual(stringWriter.ToString(), emptyCanvasString); rectangleCommandHandler.ProcessCommand(rectangleCommand); Assert.AreEqual(stringWriter.ToString().Count(c => c.Equals('x')), 10); var canvasStringWithRectangle = MatrixToStringConverter.Convert(new char[6, 5] { { '-', '-', '-', '-', '-' }, { '|', 'x', 'x', 'x', '|' }, { '|', 'x', ' ', 'x', '|' }, { '|', 'x', ' ', 'x', '|' }, { '|', 'x', 'x', 'x', '|' }, { '-', '-', '-', '-', '-' }, }); Assert.AreEqual(stringWriter.ToString(), emptyCanvasString + canvasStringWithRectangle); bucketFillCommandHandler.ProcessCommand(fillCommand); var canvasStringWithRectangleAndBucketFilled = MatrixToStringConverter.Convert(new char[6, 5] { { '-', '-', '-', '-', '-' }, { '|', 'x', 'x', 'x', '|' }, { '|', 'x', 'p', 'x', '|' }, { '|', 'x', 'p', 'x', '|' }, { '|', 'x', 'x', 'x', '|' }, { '-', '-', '-', '-', '-' }, }); Assert.AreEqual(stringWriter.ToString(), emptyCanvasString + canvasStringWithRectangle + canvasStringWithRectangleAndBucketFilled); }
public void TestDrawHorizontalLinesCommand(string command) { Assert.NotNull(stringWriter.ToString()); Assert.AreEqual(stringWriter.ToString(), emptyCanvasString); lineHandler.ProcessCommand(command); Assert.AreEqual(stringWriter.ToString().Count(c => c.Equals('x')), 3); var lineContainingCanvas = MatrixToStringConverter.Convert(new char[4, 5] { { '-', '-', '-', '-', '-' }, { '|', ' ', ' ', ' ', '|' }, { '|', 'x', 'x', 'x', '|' }, { '-', '-', '-', '-', '-' }, }); Assert.AreEqual(stringWriter.ToString(), emptyCanvasString + lineContainingCanvas); }
public void TestDrawValidRectangleCommand(string command) { Assert.NotNull(stringWriter.ToString()); Assert.AreEqual(stringWriter.ToString(), emptyCanvasString); rectangleCommandHandler.ProcessCommand(command); Assert.AreEqual(stringWriter.ToString().Count(c => c.Equals('x')), 8); var canvasStringWithRectangle = MatrixToStringConverter.Convert(new char[6, 5] { { '-', '-', '-', '-', '-' }, { '|', 'x', 'x', 'x', '|' }, { '|', 'x', ' ', 'x', '|' }, { '|', 'x', 'x', 'x', '|' }, { '|', ' ', ' ', ' ', '|' }, { '-', '-', '-', '-', '-' }, }); Assert.AreEqual(stringWriter.ToString(), emptyCanvasString + canvasStringWithRectangle); }