public void RobotCleanerReport() { RobotsCommands сommandFactory = new RobotsCommands(); сommandFactory.AddInput("4"); сommandFactory.AddInput("0 0"); сommandFactory.AddInput("N 10"); сommandFactory.AddInput("E 10"); сommandFactory.AddInput("S 10"); сommandFactory.AddInput("W 10"); Commands commandSet = сommandFactory.GetCommandSet(); // creating the report IReport testReporter = new SimpleReporter(); // creating the robot CleanerRobot cleanerRobot = new CleanerRobot(commandSet, testReporter); // moving the robot cleanerRobot.Run(); // gethering the report string whereHaveYouBeen = cleanerRobot.PrintReport(); // Assert.AreEqual("=> Cleaned: 0", whereHaveYouBeen); // We are doing complete loop // And Robot comming back to 0 0 Assert.AreEqual("=> Cleaned: 40", whereHaveYouBeen); Assert.AreEqual(commandSet.startPosition.x, cleanerRobot.location.x); Assert.AreEqual(commandSet.startPosition.y, cleanerRobot.location.y); }
static void Main(string[] args) { Console.WriteLine("Application Starts..."); Console.WriteLine("Ready For Input"); Console.WriteLine("Example Input:"); Console.WriteLine("4 (commands)"); Console.WriteLine("10 10 (start position)"); Console.WriteLine("W 10 (west 10)"); Console.WriteLine("N 4 (north 4)"); Console.WriteLine("E 14 (east 14)"); Console.WriteLine("5 20 (south 20)"); RobotsCommands commandFactory = new RobotsCommands(); while (!commandFactory.InputsCompleated) { // Adding Robot Inputs commandFactory.AddInput(Console.ReadLine()); } Console.WriteLine("Robot Instructions are complete."); Console.ReadLine(); // robot executing input commands SimpleReporter jobReporter = new SimpleReporter(); CleanerRobot cleanerRobot = new CleanerRobot(commandFactory.GetCommandSet(), jobReporter, new Location(0, 0), new Location(12, 12)); cleanerRobot.Run(); //give output on the number of places cleaned Console.WriteLine(cleanerRobot.PrintReport()); }
public void MovingRobotTest() { RobotsCommands сommandFactory = new RobotsCommands(); сommandFactory.AddInput("4"); сommandFactory.AddInput("0 0"); сommandFactory.AddInput("N 10"); сommandFactory.AddInput("E 10"); сommandFactory.AddInput("S 10"); сommandFactory.AddInput("W 10"); Commands commandSet = сommandFactory.GetCommandSet(); CleanerRobot cleanerRobot = new CleanerRobot(commandSet, null); // moving the robot cleanerRobot.Run(); Assert.AreEqual(commandSet.startPosition.x, cleanerRobot.location.x); Assert.AreEqual(commandSet.startPosition.y, cleanerRobot.location.y); }