コード例 #1
0
        public MoveCommandTests()
        {
            var factory = new ContainerFactory();

            context          = factory.Resolve <IModuleContext>();
            directionManager = context.Resolve <IDirectionManager>();
            commandManager   = context.Resolve <ICommandManager>();
        }
コード例 #2
0
        public void Should_LandAtOriginTile_When_NoSpesificPositionGiven()
        {
            var planet    = new Planet().With(10, 20, "TestPlanet");
            var direction = directionManager.GetDirections().First(d => d.Code == "N");
            var rover     = context.Resolve <Rover>();

            var roverLocation = rover.Land(planet, direction);

            Assert.AreEqual(planet.GetOriginTile().Position, roverLocation.Position);
            Assert.AreEqual(direction, roverLocation.Direction);
        }
コード例 #3
0
        public Rover CreateRoverAndLand(Planet planet, Location location)
        {
            var rover = context.Resolve <Rover>();

            rover.Land(planet, location);
            return(rover);
        }
コード例 #4
0
        public RoverTest()
        {
            var containerFactory = new ContainerFactory();

            context          = containerFactory.Resolve <IModuleContext>();
            directionManager = context.Resolve <IDirectionManager>();
        }
コード例 #5
0
        public void Should_MoveNorth_When_TargetTileIsExist()
        {
            int x = 5, y = 5;
            var planet    = new Planet().With(10, 20, "TestPlanet");
            var direction = directionManager.GetDirections().First(d => d.Code == "N");
            var location  = new Location().With(new Position(x, y), direction);
            var rover     = context.Resolve <Rover>();

            rover.Land(planet, location);

            var expectedLocationAfterMove = new Location().With(new Position(x, y + 1), direction);
            var command = commandManager.GetCommands().First(c => c.Code == "M");

            commandManager.Apply(rover, command);


            Assert.AreEqual(expectedLocationAfterMove.Position, rover.Location.Position);
            Assert.AreEqual(expectedLocationAfterMove.Direction, rover.Location.Direction);
        }