示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Mystic Countries app!");
            Console.WriteLine("Please provide the number of rows of the world map (M):");
            var rowsCount = int.Parse(Console.ReadLine());

            Console.WriteLine("Please provide the number of columns of the world map (N):");
            var columnsCount = int.Parse(Console.ReadLine());

            Console.WriteLine("Please provide the number of nations (K):");
            var worldMapNationsCount = int.Parse(Console.ReadLine());

            var map = new WorldMap
            {
                ColumnCount  = columnsCount,
                RowCount     = rowsCount,
                NationsCount = worldMapNationsCount
            };

            map.RandomizeNations();
            Console.WriteLine(map.ToString());

            var mapScanner = new WorldMapScanner(map);

            mapScanner.ScanCountries();
            Console.WriteLine(map.RenderCountries());


            Console.WriteLine("The end!");
            Console.ReadKey();
        }
示例#2
0
        public void ScanCountries_ShouldReturnFourCountries_ForTheGivenTask()
        {
            //some set up
            var map        = new WorldMap();
            var mapScanner = new WorldMapScanner(map);

            //assuming that we've got a world map matrix
            map.ImportMap(new int[3, 3]
            {
                { 0, 1, 1 },
                { 0, 2, 1 },
                { 2, 2, 0 }
            });

            //we scan the countries
            mapScanner.ScanCountries();

            //the result
            Assert.AreEqual(4, map.CountryCount);
        }