本文整理汇总了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"));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}