public void Test_For_Obstacle_Detection() { Rover rover = new Rover(); rover.PositionHeading = "E"; Navigation navigation = new Navigation(rover); string headingIndex = navigation.GetDirectionalHeading(); rover.PositionY = 0; rover.PositionX = 0; rover.LandscapeHeight = 5; rover.LandscapeWidth = 5; Landscape landscape = new Landscape(rover); landscape.BuildLandscapeGrid(false); //set obstacle Coordinates crd = new Coordinates { xCoordinate = 1, yCoordinate = 0 }; Coordinates coor = (from Coordinates in rover.gridCoordinates where Coordinates.xCoordinate == 1 && Coordinates.yCoordinate == 0 select Coordinates).FirstOrDefault <Coordinates>(); bool notNull = coor != null; int indexOf = -1; if (coor != null) { indexOf = rover.gridCoordinates.IndexOf(coor); } //int indexOf = rover.gridCoordinates.IndexOf(crd); bool hasIndex = indexOf > 0; if (hasIndex) { rover.gridCoordinates[indexOf].containsObstacle = true; } string rtnMessage = ""; char[] cmds = ("f").ToCharArray(); while (!rover.ReportObstacle) { foreach (char c in cmds) { rtnMessage = rover.Command_Parser(c.ToString()); } //break; } Assert.AreEqual(true, rtnMessage.Contains("Obst")); }
public void Test_Rover_Turns_East() { Rover rover = new Rover(); rover.PositionHeading = "n"; Navigation navigation = new Navigation(rover); rover.Command_Parser("R"); Assert.AreEqual("E", navigation.GetDirectionalHeading()); }