Beispiel #1
0
        public void Create_Should_Throw_InvalidSizeException_When_Negative_Size()
        {
            //When
            var exception = new Exception("Plateau size not valid");

            //When
            var ex = Assert.Throws <Exception>(() => _plateauService.Create(-1, 5));

            //Than
            Assert.AreEqual("Plateau size not valid", ex.Message);
        }
        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);
        }
        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);
        }
        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);
        }