コード例 #1
0
        public void TestIntersectionSingle()
        {
            var block = TestBlock.Create(
                "   ",
                " X ",
                "   ");

            var grid = new BlockGrid(3, 3);

            grid.Freeze(block);


            Assert.True(grid.Intersects(block.At(0, 0)));

            for (var dy = -1; dy <= 1; dy++)
            {
                for (var dx = -1; dx <= 1; dx++)
                {
                    if (dx == 0 && dy == 0)
                    {
                        continue;
                    }

                    Assert.False(grid.Intersects(block.At(dx, dy)));
                }
            }
        }
コード例 #2
0
        public void TestIntersectionLineHorizontal()
        {
            var block = TestBlock.Create(
                "   ",
                "XXX",
                "   "
                );
            var grid = new BlockGrid(3, 3);

            grid.Freeze(block);


            Assert.True(grid.Intersects(block.At(0, 0)));
            Assert.False(grid.Intersects(block.At(0, -1)));
            Assert.False(grid.Intersects(block.At(0, 1)));
        }
コード例 #3
0
        public void TestIntersectionLineVertical()
        {
            var block = TestBlock.Create(
                " X ",
                " X ",
                " X "
                );

            var grid = new BlockGrid(3, 3);

            grid.Freeze(block);

            Assert.True(grid.Intersects(block.At(0, 0)));
            Assert.False(grid.Intersects(block.At(1, 0)));
            Assert.False(grid.Intersects(block.At(-1, 0)));
        }
コード例 #4
0
        public void TestOverlap()
        {
            var block = TestBlock.Create(
                "XXX",
                "XXX",
                "XXX"
                );

            var grid = new BlockGrid(9, 9);

            grid.Freeze(block.At(3, 3));

            Assert.False(grid.Intersects(block.At(0, 0)));
            Assert.False(grid.Intersects(block.At(4, 0)));
            Assert.True(grid.Intersects(block.At(4, 1)));
            Assert.False(grid.Intersects(block.At(0, 3)));
            Assert.False(grid.Intersects(block.At(6, 6)));
            Assert.False(grid.Intersects(block.At(4, 6)));
        }