예제 #1
0
        static void ProcessInputResult(string[] mineMapLines)
        {
            var mineGrid       = MineGridGenerator.Generate(mineMapLines);
            var mineGridString = MineGridStringConverter.Convert(mineGrid);

            Console.WriteLine();
            WriteAndReset(mineGridString);
        }
예제 #2
0
        void TestMineGridGenerating(int width, int height, string[] input, int[,] output)
        {
            var fields = MineGridGenerator.Generate(input);

            Assert.IsNotNull(fields);
            Assert.AreEqual(width, fields.Width);
            Assert.AreEqual(height, fields.Height);
            Assert.AreEqual(width * height, fields.Count);

            var fieldNearbyCountMap = new int[fields.Height, fields.Width];

            foreach (var field in fields)
            {
                fieldNearbyCountMap[field.Y, field.X] = field.IsMine ? -1 : field.NearbyMineCount;
            }

            for (int y = 0; y < fields.Height; y++)
            {
                for (int x = 0; x < fields.Width; x++)
                {
                    Assert.AreEqual(output[y, x], fieldNearbyCountMap[y, x]);
                }
            }
        }