Пример #1
0
        public void ShouldNotAllowIfXIsOutOfCanvas()
        {
            string[,] canvas = new string[5, 5];
            Rectangle rectangle = new Rectangle(6, 3, 6, 4);

            Assert.IsFalse(rectangle.IsValid(canvas));
        }
Пример #2
0
        public void ShouldNotAllowIfYIsOutOfCanvas()
        {
            var canvas = new string[5, 5];
            Rectangle rectangle = new Rectangle(1, 8, 1, 4);

            Assert.IsFalse(rectangle.IsValid(canvas));
        }
Пример #3
0
        public void ShouldDrawARectangle()
        {
            var canvas = new string[5, 5];
            Rectangle rectangle = new Rectangle(1, 1, 3, 3);

            Assert.IsTrue(rectangle.IsValid(canvas));

            var drawnCanvas = rectangle.DrawToCanvas(canvas);

            Assert.IsNotNull(drawnCanvas);
            Assert.AreEqual(null, drawnCanvas.GetValue(0, 0));
            Assert.AreEqual("x", drawnCanvas.GetValue(1, 1));
            Assert.AreEqual("x", drawnCanvas.GetValue(1, 2));
            Assert.AreEqual("x", drawnCanvas.GetValue(1, 3));
            Assert.AreEqual(null, drawnCanvas.GetValue(1, 4));

            Assert.AreEqual(null, drawnCanvas.GetValue(2, 0));
            Assert.AreEqual("x", drawnCanvas.GetValue(2, 1));
            Assert.AreEqual(null, drawnCanvas.GetValue(2, 2));
            Assert.AreEqual("x", drawnCanvas.GetValue(2, 3));
            Assert.AreEqual(null, drawnCanvas.GetValue(2, 4));

            Assert.AreEqual(null, drawnCanvas.GetValue(3, 0));
            Assert.AreEqual("x", drawnCanvas.GetValue(3, 1));
            Assert.AreEqual("x", drawnCanvas.GetValue(3, 2));
            Assert.AreEqual("x", drawnCanvas.GetValue(3, 3));
            Assert.AreEqual(null, drawnCanvas.GetValue(3, 4));
        }