public void TestCanvasAddSprite() { int width = 3; int height = 3; char c = 'w'; SpriteEntity line = new Line( new Point(2, 1), new Point(2, 3), c ); Canvas canvas = new Canvas(width, height); canvas.AddSprite(line); Char[,] canvasArray = canvas.GetCanvasArray(); Assert.AreEqual(c, canvasArray[2, 1]); Assert.AreEqual(c, canvasArray[2, 2]); Assert.AreEqual(c, canvasArray[2, 3]); Assert.AreNotEqual(c, canvasArray[1, 1]); Assert.AreNotEqual(c, canvasArray[1, 2]); Assert.AreNotEqual(c, canvasArray[1, 3]); Assert.AreNotEqual(c, canvasArray[3, 1]); Assert.AreNotEqual(c, canvasArray[3, 2]); Assert.AreNotEqual(c, canvasArray[3, 3]); }
public void TestCanvasDrawWithSprite() { int width = 3; int height = 3; StringBuilder sb = new StringBuilder(); sb.Append("-----").Append(Environment.NewLine); sb.Append("|\0x\0|").Append(Environment.NewLine); sb.Append("|\0x\0|").Append(Environment.NewLine); sb.Append("|\0x\0|").Append(Environment.NewLine); sb.Append("-----").Append(Environment.NewLine); string expected = sb.ToString(); Canvas canvas = new Canvas(width, height); SpriteEntity line = new Line( new Point(2, 1), new Point(2, 3), 'x' ); canvas.AddSprite(line); string actual = canvas.Render(); Assert.AreEqual(expected, actual); }