Ejemplo n.º 1
0
        public void FromCenter_ReturnRegion_CheckBoarders()
        {
            var roi = RegionHelper.FromCenter(5, 10, 5, 9);

            Assert.AreEqual(5, roi.Height);
            Assert.AreEqual(9, roi.Width);
            Assert.AreEqual(3, roi.Top);
            // I'm not really sure if this is correct
            Assert.AreEqual(8, roi.Bottom);
            Assert.AreEqual(6, roi.Left);
            Assert.AreEqual(15, roi.Right);
        }
Ejemplo n.º 2
0
        public void GetFromRegion()
        {
            var mat = MatrixPopulator.CreateIncrementedInt(9, 9);

            var matReg = mat.GetRect(RegionHelper.FromCenter(3, 2, 3, 5));

            var expectedBox = new Matrix <int>(new[, ]
            {
                { 19, 20, 21, 22, 23 },
                { 28, 29, 30, 31, 32 },
                { 37, 38, 39, 40, 41 }
            });

            Assert.AreEqual(expectedBox, matReg);
        }
Ejemplo n.º 3
0
        public void FromCenter_ReturnRegion_CheckBoarders2()
        {
            var roi = RegionHelper.FromCenter(5, 6, 3, 3);

            /*  x	  0  1  2  3  4  5  6  7  8  9 x
             * y	+--+--+--+--+--+--+--+--+--+--+
             * 0	|  |  |  |  |  |  |  |  |  |  |
             *      +--+--+--+--+--+--+--+--+--+--+
             * 1	|  |  |  |  |  |  |  |  |  |  |
             *      +--+--+--+--+--+--+--+--+--+--+
             * 2	|  |  |  |  |  |  |  |  |  |  |
             *      +--+--+--+--+--+--+--+--+--+--+
             * 3	|  |  |  |  |  |  |  |  |  |  |
             *      +--+--+--+--+--+--+--+--+--+--+
             * 4	|  |  |  |  |  |++|++|++|  |  |
             *      +--+--+--+--+--+--+--+--+--+--+
             * 5	|  |  |  |  |  |++|**|++|  |  |
             *      +--+--+--+--+--+--+--+--+--+--+
             * 6	|  |  |  |  |  |++|++|++|  |  |
             *      +--+--+--+--+--+--+--+--+--+--+
             * 7	|  |  |  |  |  |  |  |  |  |  |
             *      +--+--+--+--+--+--+--+--+--+--+
             * 8	|  |  |  |  |  |  |  |  |  |  |
             *      +--+--+--+--+--+--+--+--+--+--+
             * 9	|  |  |  |  |  |  |  |  |  |  |
             * y	+--+--+--+--+--+--+--+--+--+--+
             */

            Assert.AreEqual(3, roi.Height);
            Assert.AreEqual(3, roi.Width);
            Assert.AreEqual(4, roi.Top);
            // I'm not really sure if this is correct
            Assert.AreEqual(7, roi.Bottom);
            Assert.AreEqual(5, roi.Left);
            Assert.AreEqual(8, roi.Right);
        }
Ejemplo n.º 4
0
 public void FromCenter_ReturnRegion_ToSmallHeight_ThrowsError()
 {
     Assert.Catch <OutOfRangeException>(() => RegionHelper.FromCenter(5, 10, 5, 1));
 }
Ejemplo n.º 5
0
 public void FromCenter_ReturnRegion_ToSmallWidth_ThrowsError()
 {
     Assert.Catch <Exception>(() => RegionHelper.FromCenter(5, 10, 1, 4));
 }
Ejemplo n.º 6
0
 public void FromCenter_ReturnRegion_EvenHeight_ThrowsError()
 {
     Assert.Catch <Exception>(() => RegionHelper.FromCenter(5, 10, 4, 5));
 }