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


C# Rover.MoveForward方法代码示例

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


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

示例1: TestMoveForward

        public void TestMoveForward()
        {
            var rover = new Rover(new Point { X = 0, Y = 0 }, 'E', stateFactory, planet);
            rover.MoveForward();

            Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("1,0"));
        }
开发者ID:kevPo,项目名称:MarsRover,代码行数:7,代码来源:FacingEastTests.cs

示例2: TestEncounterObstacleOnOtherSideOfAxisAndDoesNotMoveForward

        public void TestEncounterObstacleOnOtherSideOfAxisAndDoesNotMoveForward()
        {
            var planetWithObstruction = new Planet(50, new Point[] { new Point { X = -25, Y = 0 } });
            var rover = new Rover(new Point { X = 25, Y = 0 }, 'E', stateFactory, planetWithObstruction);
            rover.MoveForward();

            Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("25,0"));
        }
开发者ID:kevPo,项目名称:MarsRover,代码行数:8,代码来源:FacingEastTests.cs

示例3: TestEnountersObstructionAndDoesNotMoveForward

        public void TestEnountersObstructionAndDoesNotMoveForward()
        {
            var planetWithObstruction = new Planet(50, new Point[] { new Point { X = 1, Y = 0 } });
            var rover = new Rover(new Point { X = 0, Y = 0 }, 'E', stateFactory, planetWithObstruction);
            rover.MoveForward();

            Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("0,0"));
        }
开发者ID:kevPo,项目名称:MarsRover,代码行数:8,代码来源:FacingEastTests.cs

示例4: TestRoverEncountersObstacleMovingNegatively

        public void TestRoverEncountersObstacleMovingNegatively()
        {
            var obstructionPoint = new Point { X = 2, Y = 2 };
            var planetWithObstacles = new Planet(50, new Point[] { obstructionPoint });
            var rover = new Rover(new Point { X = 3, Y = 2 }, 'W', stateFactory, planetWithObstacles);
            rover.MoveForward();

            Assert.That(rover.IsObstructed, Is.EqualTo(true));
            Assert.That(rover.Obstruction.ToString(), Is.EqualTo(obstructionPoint.ToString()));
            Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("3,2"));
        }
开发者ID:kevPo,项目名称:MarsRover,代码行数:11,代码来源:RoverTests.cs

示例5: TestRoverWrapsAroundPlanetForward

        public void TestRoverWrapsAroundPlanetForward()
        {
            var rover = new Rover(new Point { X = 0, Y = 50 }, 'N', stateFactory, planet);
            rover.MoveForward();

            Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("0,-50"));
        }
开发者ID:kevPo,项目名称:MarsRover,代码行数:7,代码来源:FacingNorthTests.cs

示例6: TestMoveRoverForwardWest

 public void TestMoveRoverForwardWest()
 {
     var rover = new Rover(pointAtZeroZero, 'W', stateFactory, planet);
     rover.MoveForward();
     Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("-1,0"));
 }
开发者ID:kevPo,项目名称:MarsRover,代码行数:6,代码来源:RoverTests.cs

示例7: TestTurnRoverRightFromNorth

 public void TestTurnRoverRightFromNorth()
 {
     var rover = new Rover(pointAtZeroZero, 'N', stateFactory, planet);
     rover.TurnRight();
     rover.TurnRight();
     rover.TurnRight();
     rover.TurnRight();
     rover.MoveForward();
     Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("0,1"));
 }
开发者ID:kevPo,项目名称:MarsRover,代码行数:10,代码来源:RoverTests.cs

示例8: TestRoverWrapsAroundYAxisMovingForwardSouth

 public void TestRoverWrapsAroundYAxisMovingForwardSouth()
 {
     var rover = new Rover(new Point { X = 0, Y = -25 }, 'S', stateFactory, planet);
     rover.MoveForward();
     Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("0,25"));
 }
开发者ID:kevPo,项目名称:MarsRover,代码行数:6,代码来源:RoverTests.cs

示例9: TestRoverWrapsAroundXAxisMovingForwardWest

 public void TestRoverWrapsAroundXAxisMovingForwardWest()
 {
     var rover = new Rover(new Point { X = -25, Y = 0 }, 'W', stateFactory, planet);
     rover.MoveForward();
     Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("25,0"));
 }
开发者ID:kevPo,项目名称:MarsRover,代码行数:6,代码来源:RoverTests.cs

示例10: TestMoveRoverForwardSouth

 public void TestMoveRoverForwardSouth()
 {
     var rover = new Rover(pointAtZeroZero, 'S', planet);
     rover.MoveForward();
     Assert.That(rover.GetCurrentPosition().ToString(), Is.EqualTo("0,-1"));
 }
开发者ID:kevPo,项目名称:VectorMarsRover,代码行数:6,代码来源:RoverTests.cs


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