public void CreateRoverShouldReturnExpectedType(RoverFactory sut) { var actual = sut.CreateRover(); actual.Should().BeOfType <Rover>(); actual.Should().BeAssignableTo <IRover>(); }
public void AddRoverToList(RoverDto roverDto) { var plateu = PlateuFactory.CreatePlateu(roverDto.Plateu.CoordinateX, roverDto.Plateu.CoordinateY); var rover = RoverFactory.CreateRover(roverDto.Id, roverDto.CoordinateX, roverDto.CoordinateY, roverDto.Direction, roverDto.Command, plateu); rovers.Add(rover); }
public void CreateRover_ReturnsIRover_WhenInputInCorrectFormat(string coordinates) { IRover rover = RoverFactory.CreateRover(coordinates, surface.Object); Assert.NotNull(rover); Assert.True(rover.X > 0 && rover.Y > 0); Assert.True(directions.Contains(rover.Direction)); }
public void Move_ReturnCorrectMovement_WhenMovementIsInSurface() { IRover rover = RoverFactory.CreateRover("1 2 N", surface.Object); rover.Move("M"); rover.Move("R"); rover.Move("M"); Assert.Equal(2, rover.X); Assert.Equal(3, rover.Y); Assert.Equal("E", rover.Direction); }
public void Test_Move_Rover(int plateuXCoordinate, int plateuYCoordinate, int roverId, int coordinateX, int coordinateY, char direction, string command, int expectedX, int expectedY, Type expectedDirection, bool isOutOfThePlateu) { var plateu = PlateuFactory.CreatePlateu(plateuXCoordinate, plateuYCoordinate); var rover = RoverFactory.CreateRover(roverId, coordinateX, coordinateY, direction, command, plateu); rover.Move(); Assert.Equal(expectedX, rover.CoordinateX); Assert.Equal(expectedY, rover.CoordinateY); Assert.Equal(expectedDirection, rover.Direction.GetType()); Assert.Equal(isOutOfThePlateu, rover.IsOutOfThePlateu); }
static void Main(string[] args) { //Test Input: //5 5 //1 2 N //LMLMLMLMM //3 3 E //MMRMMRMRRM //Expected Output: //1 3 N //5 1 E string surf = Console.ReadLine(); //5 5 ISurface surface = SurfaceFactory.CreateSurface(surf); string rov = Console.ReadLine(); //1 2 N IRover rover = RoverFactory.CreateRover(rov, surface); string moves = Console.ReadLine(); //LMLMLMLMM List <string> movements = MovementFactory.CreateMovement(moves); foreach (var movement in movements) { rover.Move(movement); } string rov2 = Console.ReadLine(); //3 3 E IRover rover2 = RoverFactory.CreateRover(rov2, surface); string moves2 = Console.ReadLine(); //MMRMMRMRRM List <string> movements2 = MovementFactory.CreateMovement(moves2); foreach (var movement2 in movements2) { rover2.Move(movement2); } Console.WriteLine($"{rover.X} {rover.Y} {rover.Direction}"); Console.WriteLine($"{rover2.X} {rover2.Y} {rover2.Direction}"); Console.ReadLine(); }
public void Move_ThrowsRoverIsOurOfRangeException_WhenYCoordinateIsBiggerThanSufaceY() { IRover rover = RoverFactory.CreateRover("2 5 N", surface.Object); Assert.Throws <ArgumentException>(() => rover.Move("M")); }
public void Move_ThrowsMovementCodeInvalidException_WhenMovementCodeIsInvalid(string code) { IRover rover = RoverFactory.CreateRover("1 2 N", surface.Object); Assert.Throws <ArgumentException>(() => rover.Move(code)); }
public void CreateRover_ThrowsDirectionException_WhenThirdCharIsNotaDirection(string coordinates) { Assert.Throws <ArgumentException>(() => RoverFactory.CreateRover(coordinates, surface.Object)); }
public void CreateRover_ThrowsIntegerTypeException_WhenFirstTwoCharacterHasChar(string coordinates) { Assert.Throws <ArgumentException>(() => RoverFactory.CreateRover(coordinates, surface.Object)); }
public void CreateRover_ThrowsLengthException_WhenInputStringNotHasOnlyTwoSpace(string coordinates) { Assert.Throws <ArgumentException>(() => RoverFactory.CreateRover(coordinates, surface.Object)); }