Esempio n. 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);
        }
        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);
        }