当前位置: 首页>>代码示例>>C#>>正文


C# Rover.ProcessInstructions方法代码示例

本文整理汇总了C#中Rover.ProcessInstructions方法的典型用法代码示例。如果您正苦于以下问题:C# Rover.ProcessInstructions方法的具体用法?C# Rover.ProcessInstructions怎么用?C# Rover.ProcessInstructions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rover的用法示例。


在下文中一共展示了Rover.ProcessInstructions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: when_updated_position_is_outside_the_plateau

        public void when_updated_position_is_outside_the_plateau()
        {
            var initialPosition = new Position(1, 2, Direction.North);
            var updatedPosition = new Position(10, 20, Direction.South);

            _instructionHandler.Stub(x => x.Handle("L", initialPosition)).Return(updatedPosition);

            var rover = new Rover(initialPosition, _plateau, _instructionHandler);

            "It should throw an exception".AssertThrows<InvalidOperationException>(() => rover.ProcessInstructions("L"));
        }
开发者ID:odw1,项目名称:Katas,代码行数:11,代码来源:RoverTests.cs

示例2: when_moving_the_second_rover

        public void when_moving_the_second_rover()
        {
            var plateau = new Plateau(5, 5);
            var initialPosition = new Position(3, 3, Direction.East);
            var rover = new Rover(initialPosition, plateau, new InstructionHandler());
            rover.ProcessInstructions("MMRMMRMRRM");

            var position = rover.Position;

            "It should be at x coordinate".AssertThat(position.X, Is.EqualTo(5));
            "It should be at y coordinate".AssertThat(position.Y, Is.EqualTo(1));
            "It should be facing north".AssertThat(position.Direction, Is.EqualTo(Direction.East));
        }
开发者ID:odw1,项目名称:Katas,代码行数:13,代码来源:RoverEndToEndTests.cs

示例3: when_moving_the_first_rover

        public void when_moving_the_first_rover()
        {
            var plateau = new Plateau(5, 5);
            var initialPosition = new Position(1, 2, Direction.North);
            var rover = new Rover(initialPosition, plateau, new InstructionHandler());
            rover.ProcessInstructions("LMLMLMLMM");

            var position = rover.Position;

            "It should be at x coordinate".AssertThat(position.X, Is.EqualTo(1));
            "It should be at y coordinate".AssertThat(position.Y, Is.EqualTo(3));
            "It should be facing north".AssertThat(position.Direction, Is.EqualTo(Direction.North));
        }
开发者ID:odw1,项目名称:Katas,代码行数:13,代码来源:RoverEndToEndTests.cs

示例4: when_processing_instructions

        public void when_processing_instructions()
        {
            var initialPosition = new Position(1, 2, Direction.North);
            var updatedPosition = new Position(4, 4, Direction.South);

            _instructionHandler.Stub(x => x.Handle("L", initialPosition)).Return(updatedPosition);

            var rover = new Rover(initialPosition, _plateau, _instructionHandler);

            rover.ProcessInstructions("L");

            "It should update the rovers position".AssertThat(rover.Position, Is.EqualTo(updatedPosition));
        }
开发者ID:odw1,项目名称:Katas,代码行数:13,代码来源:RoverTests.cs

示例5: when_processing_multiple_instructions

        public void when_processing_multiple_instructions()
        {
            var initialPosition = new Position(1, 2, Direction.North);
            var position = new Position(1, 2, Direction.North);

            _instructionHandler.Stub(x => x.Handle(null, null)).IgnoreArguments().Repeat.Times(3).Return(position);

            var rover = new Rover(initialPosition, _plateau, _instructionHandler);

            rover.ProcessInstructions("LMR");

            "It should ask the handler to turn the rover left".AssertWasCalled(_instructionHandler, x => x.Handle("L", initialPosition));
            "It should ask the handler to move the rover fowards".AssertWasCalled(_instructionHandler, x => x.Handle("M", position));
            "It should ask the handler to turn the rover right".AssertWasCalled(_instructionHandler, x => x.Handle("R", position));
        }
开发者ID:odw1,项目名称:Katas,代码行数:15,代码来源:RoverTests.cs


注:本文中的Rover.ProcessInstructions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。