public void GenerateExplorationReportTest_TwoExplorersCollide_ExpectedOutput() { var deploymentZone = new Plateau { Size = new Size(5, 5) }; var team = new ExplorationTeam(deploymentZone); var rover1 = new Rover(team); var rover2 = new Rover(team); rover1.Launch(new Position(5, 5), Heading.North); team.Add(rover1); rover1.Move(new List <Movement>()); rover2.Launch(new Position(5, 4), Heading.North); team.Add(rover2); rover2.Move(new List <Movement> { // MMRMMRMRRM Movement.Forward, Movement.Forward, Movement.Forward }); var expectedReport = new StringBuilder(); expectedReport.Append("5 5 N"); expectedReport.AppendLine(); expectedReport.Append("5 4 N"); expectedReport.AppendLine(); Assert.AreEqual(expectedReport.ToString(), team.GenerateExplorationReport()); }
/// <summary> /// Create the mission control center (MCC) that is responsible for the provided deployment zone. /// </summary> /// <param name="deploymentZone">The zone that this MCC is responsible for exploring with its exploration crew.</param> /// <exception cref="ArgumentNullException">Thrown if provided deployment zone is null.</exception> public MissionControlCenter(IDeploymentZoneChart deploymentZone) { DeploymentDestination = deploymentZone ?? throw new ArgumentNullException(nameof(deploymentZone), "Deployment zone cannot be null."); Explorers = new ExplorationTeam(deploymentZone); _setCommandChainExecutors = new Dictionary <CommandChainType, Action <IExplorerCommand> > { { CommandChainType.InitializeDeploymentZone, command => { var deploymentZoneChartCommand = (DeploymentZoneChartCommand)command; deploymentZoneChartCommand.SetDeploymentZoneChart(DeploymentDestination); } }, { CommandChainType.DeployExplorer, command => { var deployExplorerCommand = (DeployExplorerCommand)command; var rover = new Rover(Explorers); deployExplorerCommand.SetExplorer(rover); Explorers.Add(rover); } }, { CommandChainType.Explore, command => { var exploreCommand = (ExploreCommand)command; exploreCommand.SetExplorer(Explorers.Last()); } } }; }
public void GenerateExplorationReportTest_HitWall_ExpectedOutput() { var deploymentZone = new Plateau { Size = new Size(5, 5) }; var team = new ExplorationTeam(deploymentZone); var rover = new Rover(team); rover.Launch(new Position(5, 5), Heading.North); team.Add(rover); rover.Move(new List <Movement> { Movement.Forward, Movement.Forward, Movement.Forward, Movement.Forward, Movement.Forward, Movement.Forward, Movement.Forward, Movement.Forward, Movement.Forward, Movement.Forward, Movement.Forward }); var expectedReport = new StringBuilder(); expectedReport.Append("5 5 N"); expectedReport.AppendLine(); Assert.AreEqual(expectedReport.ToString(), team.GenerateExplorationReport()); }
public void GenerateExplorationReportTest_ExplorerNotLaunched_ExpectedOutput() { var team = new ExplorationTeam(new Plateau()); team.Add(new Rover(team)); var expectedReport = new StringBuilder(); expectedReport.Append("Explorer not launched."); expectedReport.AppendLine(); Assert.AreEqual(expectedReport.ToString(), team.GenerateExplorationReport()); }
public void MoveTest() { var deploymentZone = new Plateau { Size = new Size(5, 5) }; var team = new ExplorationTeam(deploymentZone); var rover1 = new Rover(team); var rover2 = new Rover(team); rover1.Launch(new Position(1, 2), Heading.North); team.Add(rover1); rover1.Move(new List <Movement> { // LMLMLMLMM Movement.Left, Movement.Forward, Movement.Left, Movement.Forward, Movement.Left, Movement.Forward, Movement.Left, Movement.Forward, Movement.Forward }); rover2.Launch(new Position(3, 3), Heading.East); team.Add(rover2); rover2.Move(new List <Movement> { // MMRMMRMRRM Movement.Forward, Movement.Forward, Movement.Right, Movement.Forward, Movement.Forward, Movement.Right, Movement.Forward, Movement.Right, Movement.Right, Movement.Forward }); }
public void IsPositionAvailableTest_PassIsValidAndnoExplorerAtPosition() { var team = new ExplorationTeam(new Plateau { Size = new Size(5, 5) }); var rover1 = new Rover(team); rover1.Launch(new Position(5, 5), Heading.North); team.Add(rover1); var rover2 = new Rover(team); Assert.IsTrue(rover2.IsPositionAvailable(new Position(4, 5))); }
public void IsPositionAvailableTest_ExplorerExistsAtPositionFails() { var team = new ExplorationTeam(new Plateau { Size = new Size(5, 5) }); var rover1 = new Rover(team); rover1.Launch(new Position(5, 5), Heading.North); team.Add(rover1); var rover2 = new Rover(team); Assert.IsFalse(rover2.IsPositionAvailable(new Position(5, 5))); }
public void GenerateExplorationReportTest_OneExplorerLaunched_ExpectedOutput() { var deploymentZone = new Plateau { Size = new Size(5, 5) }; var team = new ExplorationTeam(deploymentZone); var rover = new Rover(team); rover.Launch(new Position(1, 2), Heading.North); team.Add(rover); var expectedReport = new StringBuilder(); expectedReport.Append("1 2 N"); expectedReport.AppendLine(); Assert.AreEqual(expectedReport.ToString(), team.GenerateExplorationReport()); }