public void AddMarsRover_Should_Add_Mars_Rover_Plateau_When_Second_Expected_Value()
        {
            //Arrange
            var plateauService = new PlateauService(_loggerMock);

            plateauService.Create(6, 6);
            plateauService.AddMarsRover(new RoverPositionModel
            {
                Direction = Direction.East,
                X         = 5,
                Y         = 3
            });

            var roverPositionModel = new RoverPositionModel
            {
                Direction = Direction.East,
                X         = 1,
                Y         = 2
            };


            //Act
            plateauService.AddMarsRover(roverPositionModel);
            //Assert

            plateauService.GetMarsRovers().Count.Should().Be(2);
            plateauService.GetMarsRovers().Last().X.Should().Be(roverPositionModel.X);
            plateauService.GetMarsRovers().Last().Y.Should().Be(roverPositionModel.Y);
            plateauService.GetMarsRovers().Last().Direction.Should().Be(roverPositionModel.Direction);
        }
예제 #2
0
        static void Main(string[] args)
        {
            bool validPlateauInfo = false;

            while (!validPlateauInfo)
            {
                Console.WriteLine("Lütfen platonun X ve Y koordinatlarını girin:");
                var plateauInfo = Console.ReadLine();
                validPlateauInfo = PlateauService.SetCoordinate(plateauInfo);
            }

            while (true)
            {
                bool  validRoverPosition = false;
                Rover rover = new Rover();
                while (!validRoverPosition)
                {
                    Console.WriteLine("Lütfen gezginin konumunu girin:");
                    var roverPostionInfo = Console.ReadLine();
                    validRoverPosition = rover.SetPosition(roverPostionInfo);
                }

                Console.WriteLine("Lütfen gezgin için komut girin:");
                var command = Console.ReadLine();

                rover.RunCommand(command);

                Console.WriteLine();
                var getPostion = rover.GetPostion();
                Console.WriteLine("Gezginin mevcut konumu:");
                Console.WriteLine(getPostion);
                Console.WriteLine();
            }
        }
예제 #3
0
        public void Create_Plateau_Test_Exception_With_Two_Character()
        {
            string          coordinates    = "e e";
            IPlateauService plateauService = new PlateauService();

            plateauService.CreatePlateau(coordinates);
        }
예제 #4
0
        public void Create_Plateau_Test_Exception_Empty()
        {
            string          coordinates    = "5";
            IPlateauService plateauService = new PlateauService();

            plateauService.CreatePlateau(coordinates);
        }
예제 #5
0
        public void CheckRover()
        {
            PlateauService.SetCoordinate("5 5");
            Rover rover = new Rover(new Position(1, 2), Direction.North);

            rover.RunCommand("LMLMLMLMM");
            var output = rover.GetPostion();

            Assert.AreEqual(output, "1 3 N");
        }
예제 #6
0
        public void Create_Plateau_Test()
        {
            string          coordinates    = "5 5";
            IPlateauService plateauService = new PlateauService();

            plateauService.CreatePlateau(coordinates);

            Assert.AreEqual(plateauService.Plateau.UpperX, 5);
            Assert.AreEqual(plateauService.Plateau.UpperY, 5);
        }
예제 #7
0
        public PlateauServiceTest()
        {
            //Given
            _loggerMock     = new Mock <ILogger <PlateauService> >();
            _plateauService = new PlateauService(_loggerMock.Object);

            _roverPositionModel = new RoverPositionModel
            {
                Direction = Direction.North,
                X         = 1,
                Y         = 1
            };
        }
예제 #8
0
        public void Is_Valid_Coordinate_X_False_Test()
        {
            string          coordinates    = "5 5";
            IPlateauService plateauService = new PlateauService();

            plateauService.CreatePlateau(coordinates);

            var result = plateauService.IsValidPosition(new Models.Position {
                D = 'N', X = 6, Y = 2
            });

            Assert.AreEqual(false, result);
        }
        public void Create_Should_Create_Plateau_When_Expected_Size()
        {
            //Arrange
            var       plateauService = new PlateauService(_loggerMock);
            const int width          = 5;
            const int height         = 4;

            //Act
            plateauService.Create(width, height);
            //Assert

            plateauService.GetCurrentPlateau().Width.Should().Be(width);
            plateauService.GetCurrentPlateau().Height.Should().Be(height);
        }
예제 #10
0
        public void Create_Should_Throw_InvalidSizeException_When_Negative_Size(int width, int height)
        {
            //Arrange
            var plateauService = new PlateauService(_loggerMock);

            //Act
            void Action()
            {
                plateauService.Create(width, height);
            }

            //Assert
            Assert.Throws <ValidatePlateauSizeException>((Action)Action);
        }
예제 #11
0
        public void GivenPlateauServiceHasValidCommandThenParamsAreSet(string command)
        {
            //Arrange
            PlateauService sut            = new PlateauService(command);
            var            expectedWidth  = Convert.ToInt32(command.Split(" ")[0]);
            var            expectedHeight = Convert.ToInt32(command.Split(" ")[1]);

            //Act
            var response = sut.GetPlateau();

            //Assert
            Assert.AreEqual(expectedWidth, response.Width);
            Assert.AreEqual(expectedHeight, response.Height);
        }
예제 #12
0
 public PlateauTest()
 {
     _plateauService = new PlateauService();
 }
예제 #13
0
 public RoverTest()
 {
     _plateauService = new PlateauService();
     _roverService   = new RoverService();
 }