Exemplo n.º 1
0
            public void AddRoverCount_Valid()
            {
                string input  = "2";
                var    result = service.AddRoverCount(input);

                Assert.IsTrue(result.IsSuccess);
            }
Exemplo n.º 2
0
        public static List <RoverInfo> MissionStart(MarsRoverService service, Mission mission)
        {
            Console.BackgroundColor = ConsoleColor.Black;

            foreach (PropertyInfo propertyInfo in mission.GetType().GetProperties())
            {
                switch (propertyInfo.Name)
                {
                case nameof(mission.Plateau):
                    if (mission.Plateau.IsSuccess)
                    {
                        break;
                    }
                    Console.Write("Plateau Info :");
                    Plateau plateau = service.AddPlateu(Console.ReadLine());
                    mission.Plateau = plateau;
                    break;

                case nameof(mission.RoverCount):
                    if (mission.RoverCount.IsSuccess)
                    {
                        break;
                    }
                    Console.Write("Rover Count:");
                    RoverCount roverCount = service.AddRoverCount(Console.ReadLine());
                    mission.RoverCount = roverCount;
                    var rovers = new List <Rover>();
                    for (int i = 0; i < roverCount.Count; i++)
                    {
                        rovers.Add(new Rover());
                    }
                    mission.Rovers = rovers;
                    break;

                case nameof(mission.Rovers):
                    for (int i = 0; i < mission.RoverCount.Count; i++)
                    {
                        if (mission.Rovers[i].IsSuccess)
                        {
                            break;
                        }

                        Console.WriteLine($"{i} - Rover Setup ");
                        RoverInfo roverInfo = service.SetupRoverInfo(Console.ReadLine());
                        RoverMove roverMove = service.SetupRoverMove(Console.ReadLine());
                        mission.Rovers[i] = service.AddRover(roverInfo, roverMove);
                    }
                    Console.WriteLine($" Rover Setup End ");
                    break;

                default:
                    break;
                }
            }

            var result = new List <RoverInfo>();

            for (int i = 0; i < mission.RoverCount.Count; i++)
            {
                var rover         = mission.Rovers[i];
                var serviceResult = service.StartDiscovering(mission.Plateau, rover);
                result.Add(serviceResult);

                Console.WriteLine($"Info Mission > {i} - Rover : {serviceResult.X} {serviceResult.Y} {serviceResult.Direction}, IsSuccess:{serviceResult.IsSuccess} ");

                if (!serviceResult.IsSuccess)
                {
                    Console.WriteLine($" \t Failed Detail: { serviceResult.ErrorMessage }");
                }
            }
            ;

            return(result);
        }