Example #1
0
 public void TestFillBasicBoundary()
 {
     Map map = new Map(2, 2);
     map.SetTerrain(1, 0, maskTerrain);
     Rectangle expectedRect = new Rectangle(0, 0, 2, 2);
     Rectangle rect = map.Fill(0, 1, fillTerrain);
     HashSet<PointI2D> fillBoundary = map.FillBoundary;
     // diagonal fill boundary
     Assert.AreEqual(2, fillBoundary.Count);
 }
Example #2
0
 public void TestFillComplexBoundary()
 {
     Map map = new Map(5, 5);
     // mask top and bottom rows
     for(int i=0; i<5; i++)
     {
         map.SetTerrain(i, 0, maskTerrain);
         map.SetTerrain(i, 4, maskTerrain);
     }
     // mask sides
     for(int i=1; i<4; i++)
     {
         map.SetTerrain(0, i, maskTerrain);
         map.SetTerrain(4, i, maskTerrain);
     }
     // mask center inset
     map.SetTerrain(1, 2, maskTerrain);
     Rectangle rect = map.Fill(1, 1, fillTerrain);
     Assert.AreEqual(8, map.FillBoundary.Count);
     Assert.IsTrue(map.FillBoundary.Contains(new PointI2D(1, 1)));
     Assert.IsTrue(map.FillBoundary.Contains(new PointI2D(3, 2)));
     Assert.IsTrue(map.FillBoundary.Contains(new PointI2D(1, 3)));
 }
Example #3
0
        public void TestSimpleMaskFill()
        {
            Map map = new Map(2, 2);
            map.SetTerrain(1, 0, maskTerrain);
            Rectangle expectedRect = new Rectangle(0, 0, 2, 2);
            Rectangle rect = map.Fill(0, 1, fillTerrain);
            Assert.AreEqual(expectedRect, rect);
            Assert.AreEqual(maskTerrain, map.GetTerrain(1, 0));

            Assert.AreEqual(fillTerrain, map.GetTerrain(1, 1));
            Assert.AreEqual(fillTerrain, map.GetTerrain(0, 0));
        }