Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start...");
            var fieldString = new List<string>();
            string input;
            while ((input = Console.ReadLine()) != "c")
            {
                fieldString.Add(input);
            }

            var field = string.Join(Environment.NewLine, fieldString);
            var builder = new MineFieldsBuilder();
            var result = builder.Build(field);
            Console.Write(result);
            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start...");
            var    fieldString = new List <string>();
            string input;

            while ((input = Console.ReadLine()) != "c")
            {
                fieldString.Add(input);
            }

            var field   = string.Join(Environment.NewLine, fieldString);
            var builder = new MineFieldsBuilder();
            var result  = builder.Build(field);

            Console.Write(result);
            Console.ReadLine();
        }
Example #3
0
        public void WhenInputIsNull_ResultIsNull()
        {
            var mineFields = MineFieldsBuilder.Build(null);

            Assert.IsNull(mineFields);
        }
Example #4
0
        public void WhenThereIs3LineOf4CharAndSecondCharIsAMine_ResultIsCorrect()
        {
            var mineFields = MineFieldsBuilder.Build(CreateMultiLinesField(".*..", "....", "...."));

            Assert.AreEqual(CreateMultiLinesField("1*10", "1110", "0000"), mineFields);
        }
Example #5
0
        public void WhenThereIs1LineOf4CharAndLastCharIsAMine_ResultIsCorrect()
        {
            var mineFields = MineFieldsBuilder.Build("...*");

            Assert.AreEqual("001*", mineFields);
        }
Example #6
0
        public void WhenThereIs2LineOf4CharAndFirstCharIsAMine_ResultIsCorrect()
        {
            var mineFields = MineFieldsBuilder.Build(CreateMultiLinesField("*...", "...."));

            Assert.AreEqual(CreateMultiLinesField("*100", "1100"), mineFields);
        }
Example #7
0
        public void WhenThereIs2LinesOf4NoMine_ResultIs2LinesOf4Zeros()
        {
            var mineFields = MineFieldsBuilder.Build(CreateMultiLinesField("....", "...."));

            Assert.AreEqual(CreateMultiLinesField("0000", "0000"), mineFields);
        }
Example #8
0
        public void WhenThereIs1LineOf4CharAndFirstCharIsAMine_ResultIsCorrect()
        {
            var mineFields = MineFieldsBuilder.Build("*...");

            Assert.AreEqual("*100", mineFields);
        }
Example #9
0
        public void WhenThereIs10Mine_ResultIs10Mines()
        {
            var mineFields = MineFieldsBuilder.Build("**********");

            Assert.AreEqual("**********", mineFields);
        }
Example #10
0
        public void WhenThereIs10NoMine_ResultIs10Zeros()
        {
            var mineFields = MineFieldsBuilder.Build("..........");

            Assert.AreEqual("0000000000", mineFields);
        }
Example #11
0
        public void WhenInputIsEmpty_ResultIsEmpty()
        {
            var mineFields = MineFieldsBuilder.Build("");

            Assert.AreEqual("", mineFields);
        }
Example #12
0
        public void WhenThereIs2LineOf4CharAnd2Mines_ResultIsCorrect()
        {
            var mineFields = MineFieldsBuilder.Build(CreateMultiLinesField("...*", "**.."));

            Assert.AreEqual(CreateMultiLinesField("222*", "**21"), mineFields);
        }
Example #13
0
        public void WhenThereIs1LineOf4CharAnd2CharIsAMine_ResultIsCorrect()
        {
            var mineFields = MineFieldsBuilder.Build(CreateMultiLinesField(".**."));

            Assert.AreEqual(CreateMultiLinesField("1**1"), mineFields);
        }