Beispiel #1
0
        public void WrappedAdjacentPositionsAtCorner()
        {
            var world = new World(20, 10, true);
            var positions = world.GetAdjacentPositions(0, 0);

            var expected = new[]
            {
                new {x = 19, y = 9},
                new {x = 0, y = 9},
                new {x = 1, y = 9},
                new {x = 19, y = 1},
                new {x = 0, y = 1},
                new {x = 1, y = 1},
                new {x = 19, y = 0},
                new {x = 1, y = 0}
            };

            string poss = string.Join(" | ", positions.Select(p => p.ToString()));

            Assert.True(expected.All(p => positions.Any(pp => pp.X == p.x && pp.Y == p.y)), poss);
        }
Beispiel #2
0
        public void WrappedAdjacentPositionsAtAnotherCorner()
        {
            var world = new World(20, 10, true);
            var positions = world.GetAdjacentPositions(19, 0);

            var expected = new[]
            {
                new {x = 18, y = 9},
                new {x = 19, y = 9},
                new {x = 0, y = 9},
                new {x = 18, y = 1},
                new {x = 19, y = 1},
                new {x = 0, y = 1},
                new {x = 18, y = 0},
                new {x = 0, y = 0}
            };

            Assert.True(expected.All(p => positions.Any(pp => pp.X == p.x && pp.Y == p.y)));
        }