public void Move_Run_Test() { var inputStringComandRun = new[] { "MmmRRmmmm", "M", "LMLMLMLMLMM", "MMRMM", "Rmmmmmmmmmm", "RmmmmmmmmmmM", "mmmmmmmmmm", "mmmmmmmmmmM", "MmmRRmm", "MmmRRmmmm", "RMMLLMM", "RMMLLMMM" }; var outputStringComandRun = new[] { new IComparable[]{"ERROR"}, new IComparable[]{0, 1, "N"}, new IComparable[]{"ERROR"}, new IComparable[]{2, 2, "E"}, new IComparable[]{10, 0, "E"}, new IComparable[]{"ERROR"}, new IComparable[]{0, 10, "N"}, new IComparable[]{"ERROR"}, new IComparable[]{0, 1, "S"}, new IComparable[]{"ERROR"}, new IComparable[]{0, 0, "W"}, new IComparable[]{"ERROR"} }; for (int i = 0; i < inputStringComandRun.Length; i++) { var point = new Point(0, 0); var course = new Course("N"); try { new Move(point, course, new Command(inputStringComandRun[i]), new Area(new Point(10, 10))); Assert.AreEqual(outputStringComandRun[i][0], point.X); Assert.AreEqual(outputStringComandRun[i][1], point.Y); Assert.AreEqual(outputStringComandRun[i][2], course.Direction); } catch (MoveException exceptionMove) { Assert.AreEqual("Дрон выходит из зданного поля", exceptionMove.Message); } } }
public void CourseTurnL() { var currentDirection = new[] { "N", "W", "S", "E" }; var finalDirection = new[] { "W", "S", "E", "N" }; var side = new[] { "L", "l", "E", " l ", "sd", " L" }; foreach (var element in side) { try { for (int i = 0; i < currentDirection.Length; i++) { var course = new Course(currentDirection[i]); course.Turn(element); var actual = course.Direction; Assert.AreEqual(finalDirection[i], actual); } } catch (CourseException exceptionCourse) { Assert.AreEqual("Поворот задан не правильно. Попробуйте ещё раз", exceptionCourse.Message); } } }
public void CourseDirectionTest() { var inputStringDirection = new[] { "N", "n", "E", "e", "S", "s", "W", "w", "ERROR", "ERROR" }; var outputValue = new[] { "N", "N", "E", "E", "S", "S", "W", "W", "Q", "Q" }; for (int i = 0; i < inputStringDirection.Length; i++) { try { var course = new Course(inputStringDirection[i]); var actual = course.Direction; Assert.AreEqual(outputValue[i], actual); } catch (CourseException exceptionUser) { Assert.AreEqual("Направление может быть одно из (N, E, S, W)", exceptionUser.Message); } } }
public RobotBody(Point point, Course course) { Point = point; Course = course; }