Exemple #1
0
        public void Test_RobotInputAndThenRunAndFinallyGetReport_ReportOK()
        {
            // Arrange
            var input = new RobotInput()
            {
                InitialPosition = new Position(10, 12),
                CommandCount    = 3,
                Commands        = new List <CommandInput>()
                {
                    new CommandInput("N", 5),
                    new CommandInput("E", 1),
                    new CommandInput("S", 1)
                }
            };
            var positionContext = new RobotPositioningContext();
            var robot           = new Robot(input, positionContext);

            // Act
            robot.Run();
            var totalNoOfPositionsCleaned = positionContext.GetPositionCount();
            var report = robot.Report();

            // Assert
            Assert.AreEqual(8, totalNoOfPositionsCleaned);
            Assert.AreEqual("=> Cleaned: 8", report);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            IRobotInputProcessor inputProcessor = new RobotInputProcessor();
            var input           = inputProcessor.TakeAndProcessInput(Console.ReadLine);
            var positionContext = new RobotPositioningContext();
            var robot           = new Robot(input, positionContext);

            robot.Run();
            Console.WriteLine(robot.Report());
        }
        public void TestPositionContext_AddTwoPositions_CurrentPositionReturnedOk()
        {
            // Arrange
            var context = new RobotPositioningContext();

            context.AddPosition(new Position(10, 12));
            context.AddPosition(new Position(11, 12));

            // Act
            var currentPosition = context.GetCurrentPosition();

            // Assert
            Assert.AreEqual(11, currentPosition.X);
            Assert.AreEqual(12, currentPosition.Y);
        }
        public void TestPositionContext_AddPositionWithADuplicateOne_OnePositionCountedOnlyOnce()
        {
            // Arrange
            var context = new RobotPositioningContext();

            context.AddPosition(new Position(5, 12));
            context.AddPosition(new Position(5, 13));
            context.AddPosition(new Position(5, 12));

            // Act
            var count = context.GetPositionCount();

            // Assert
            Assert.AreEqual(2, count);
        }
Exemple #5
0
        public void Test_RobotMoveEastCommandAndThenGetReport_ReportReturnedExactNoOfCleanedCount()
        {
            // Arrange
            var positionService = new RobotPositioningContext();
            var robotInput      = new RobotInput()
            {
                InitialPosition = new Position(10, 2)
            };
            var robot = new Robot(robotInput, positionService);

            robot.AddCommand(new MoveEastCommand(2, positionService));
            // Act
            robot.Run();
            var result = robot.Report();

            // Assert
            Assert.AreEqual("=> Cleaned: 3", result);
        }