public void Test_Canvas_GetInnerCanvasException() { Canvas canvas = new Canvas(new Resolution(10, 8)); #region Filling canvas for (int y = 0; y < 8; y++) for (int x = 0; x < 10; x++) { if (x == 5 && y == 2) canvas.SetColor(x, y, Color.Red); else canvas.SetColor(x, y, Color.Black); } #endregion Canvas actual = canvas.GetInnerCanvas(5, 2, new Resolution(10, 4)); }
public void Test_Canvas_GetInnerCanvas() { Canvas canvas = new Canvas(new Resolution(10, 8)); #region Filling canvas for(int y = 0; y < 8; y++) for (int x = 0; x < 10; x++) { if (x == 5 && y == 2) canvas.SetColor(x, y, Color.Red); else canvas.SetColor(x, y, Color.Black); } #endregion Canvas expectedCanvas = new Canvas(new Resolution(3, 4)); #region Filling canvas for (int y = 0; y < 4; y++) for (int x = 0; x < 3; x++) { if (x == 0 && y == 0) expectedCanvas.SetColor(x, y, Color.Red); else expectedCanvas.SetColor(x, y, Color.Black); } #endregion Canvas actual = canvas.GetInnerCanvas(5, 2, new Resolution(3, 4)); Assert.IsTrue(actual.Width == expectedCanvas.Width && actual.Height == expectedCanvas.Height); for (int y = 0; y < actual.Height; y++) for (int x = 0; x < actual.Width; x++) Assert.IsTrue(actual.GetColor(x, y) == expectedCanvas.GetColor(x, y)); }