Пример #1
0
        public void Constructor_Sets_Position_Degrees()
        {
            // Arrange
            var x = 3;
            var y = 4;
            var orientation = "E";
            var degrees = 90;

            // Act
            _sut = new Robot(x, y, orientation, _instructionsParser, _grid);

            // Assert
            Assert.AreEqual(degrees, _sut.Position.Degrees);
        }
Пример #2
0
        public void Constructor_Sets_Position_Coordinates()
        {
            // Arrange
            var x =3;
            var y= 4;
            var orientation = "E";

            // Act
            _sut = new Robot(x, y, orientation, _instructionsParser, _grid);

            // Assert
            Assert.AreEqual(x, _sut.Position.Coordinate.X);
            Assert.AreEqual(y, _sut.Position.Coordinate.Y);
        }
Пример #3
0
        public void ExecuteInstructions_Ignores_Unknown_Instructions()
        {
            // Arrange
            var expectedX = 1;
            var expectedY = 1;
            var expectedDegrees = 90;
            var instructions = "RXUWFRFRFRF";
            _sut = new Robot(1, 1, "E", _instructionsParser, _grid);

            // Act
            var result = _sut.ExecuteInstructions(instructions);

            // Assert
            Assert.AreEqual(expectedX, result.Coordinate.X);
            Assert.AreEqual(expectedY, result.Coordinate.Y);
            Assert.AreEqual(expectedDegrees, result.Degrees);
        }
Пример #4
0
        public void Execute_Instructions_Calls_InstructionParser_Parse()
        {
            // Arrange
            var instructions = "RFFL";
            var mockInstructionsParser = new Mock<IInstructionsParser>();
            mockInstructionsParser.Setup(x => x.Parse(It.IsAny<string>())).Returns(new List<Instruction>()).Verifiable();

            _sut = new Robot(0, 0, "E", mockInstructionsParser.Object, _grid);

            // Act
            _sut.ExecuteInstructions(instructions);

            // Assert
            mockInstructionsParser.VerifyAll();
        }
Пример #5
0
        public void ExecuteInstructions_Returns_Position()
        {
            // Arrange
            var instructions = "RFFL";
            _sut = new Robot(0, 0, "E", _instructionsParser, _grid);

            // Act
            var result = _sut.ExecuteInstructions(instructions);

            // Assert
            Assert.IsInstanceOf<Position>(result);
        }
Пример #6
0
        public void ExecuteInstructions_Returns_3_3_N_For_FRRFLLFFRRFLL()
        {
            // Arrange
            var expectedX = 3;
            var expectedY = 3;
            var expectedDegrees = 0;
            var instructions = "FRRFLLFFRRFLL";
            _sut = new Robot(3, 2, "N", _instructionsParser, _grid);

            // Act
            var result = _sut.ExecuteInstructions(instructions);

            // Assert
            Assert.AreEqual(expectedX, result.Coordinate.X);
            Assert.AreEqual(expectedY, result.Coordinate.Y);
            Assert.AreEqual(expectedDegrees, result.Degrees);
        }