Exemplo n.º 1
0
        public void Car_SetNegativeSpeed_ReturnsFalse()
        {
            //arrange
            Car car = CarFactory.GetCarWithTurnedOnEngine();

            //act
            var result = car.SetSpeed(-10);

            //assert
            Assert.True(result == false && car.Speed == 0, "Succeeded to set negative speed.");
        }
Exemplo n.º 2
0
        public void Car_SetSpeedWithNeutralGearSetOn_ReturnsFalse()
        {
            //arrange
            Car car = CarFactory.GetCarWithTurnedOnEngine();

            //act
            var result = car.SetSpeed(10);

            //assert
            Assert.True(result == false && car.Speed == 0, "Succeeded to set speed while gear was neutral.");
        }
Exemplo n.º 3
0
        public void Car_SetGearFromNeutralWithIncorrectValue_ReturnsFalse(Gear gear)
        {
            //arrange
            Car car = CarFactory.GetCarWithTurnedOnEngine();

            //act
            var result = car.SetGear(gear);

            //assert
            Assert.True(result == false, $"SetGear returns true when trying to set {gear} from Neutral.");
            Assert.True(car.Gear == Gear.Neutral, $"Succeeded to set {gear} from Neutral");
        }
Exemplo n.º 4
0
        public void Car_SetGearFromNeutralWithCorrectValue_ReturnsTrue(Gear gear)
        {
            //arrange
            Car car = CarFactory.GetCarWithTurnedOnEngine();

            //act
            var result = car.SetGear(gear);

            //assert
            Assert.True(result == true, $"SetGear returns false when trying to set {gear} from Neutral.");
            Assert.True(car.Gear == gear, $"Failed to set {gear} from Neutral");
        }
Exemplo n.º 5
0
        public void Car_SetGearToFirstWithCorrectParams_ReturnsTrueAndSetsFirstGear()
        {
            //arrange
            Car car = CarFactory.GetCarWithTurnedOnEngine();

            //act
            var result = car.SetGear(Gear.First);

            //assert
            Assert.True(result == true, "Failed to set first gear.");
            Assert.True(car.Gear == Gear.First, $"SetGear switched to {car.Gear} while trying to set First gear");
            Assert.True(car.Direction == Direction.OnPlace, "SetGear changed direction.");
        }
Exemplo n.º 6
0
        public void Car_TurnEngineOffWhenCarIsMoving_ReturnsFalse()
        {
            //arrange
            Car car = CarFactory.GetCarWithTurnedOnEngine();

            //act
            car.SetGear(Gear.First);
            car.SetSpeed(10);
            var result = car.TurnOffEngine();

            //assert
            Assert.True(result == false, "TurnOffEngine succeeded when car was moving.");
            Assert.True(car.IsEngineRunning == true, "TurnOffEngine turned car off when it was moving.");
        }