Ejemplo n.º 1
0
        public void MarsRoverService_ExecuteExplorationPlan_ValidExplorationPlanInput()
        {
            ExplorationPlan explorationPlan = new ExplorationPlan
            {
                Plateau = new Plateau
                {
                    LowerLefttCoordinate = new Coordinate {
                        X = 0, Y = 0
                    },
                    UpperRightCoordinate = new Coordinate {
                        X = 5, Y = 5
                    }
                },
                RoverNavigationPlanList = new List <NavigationPlan>
                {
                    new NavigationPlan
                    {
                        InitialPosition = new Position  {
                            Coordinate = new Coordinate {
                                X = 1, Y = 2
                            }, DirectionType = DirectionType.N
                        },
                        InstructionTypeSequence = new List <InstructionType>
                        {
                            InstructionType.L,
                            InstructionType.M,
                            InstructionType.L,
                            InstructionType.M,
                            InstructionType.L,
                            InstructionType.M,
                            InstructionType.L,
                            InstructionType.M,
                            InstructionType.M,
                        }
                    },
                    new NavigationPlan
                    {
                        InitialPosition = new Position  {
                            Coordinate = new Coordinate {
                                X = 3, Y = 3
                            }, DirectionType = DirectionType.E
                        },
                        InstructionTypeSequence = new List <InstructionType>
                        {
                            InstructionType.M,
                            InstructionType.M,
                            InstructionType.R,
                            InstructionType.M,
                            InstructionType.M,
                            InstructionType.R,
                            InstructionType.M,
                            InstructionType.R,
                            InstructionType.R,
                            InstructionType.M,
                        }
                    }
                }
            };

            FinalStatus expectedFinalStatus = new FinalStatus
            {
                FinalRoverPositionList = new List <Position>
                {
                    new Position {
                        Coordinate = new Coordinate {
                            X = 1, Y = 3
                        }, DirectionType = DirectionType.N
                    },
                    new Position {
                        Coordinate = new Coordinate {
                            X = 5, Y = 1
                        }, DirectionType = DirectionType.E
                    }
                }
            };

            IMarsRoverService marsRoverService  = new MarsRoverService();
            FinalStatus       actualFinalStatus = marsRoverService.ExecuteExplorationPlan(explorationPlan);

            Assert.Equal(expectedFinalStatus, actualFinalStatus);
        }
Ejemplo n.º 2
0
        public void MarsRoverService_ExecuteExplorationPlanWithMissingConstructorArgumentFinalStatusSerializer_ThrowsArgumentNullException()
        {
            string testInput = "5 5\n" +
                               "1 2 N\n" +
                               "LMLMLMLMM\n" +
                               "3 3 E\n" +
                               "MMRMMRMRRM\n";

            IMarsRoverService     marsRoverService      = new MarsRoverService(_explorationPlanDeserializer, null); // the missing parameter is finalStatusSerializer
            ArgumentNullException argumentNullException = Assert.Throws <ArgumentNullException>(() => { string actualOutput = marsRoverService.ExecuteExplorationPlan(testInput); });

            Assert.Equal("finalStatusSerializer", argumentNullException.ParamName);
        }