public void Super_hungry_car_can_try_driving_but_is_drained()
    {
        int speed        = 100;
        int batteryDrain = 60;
        var car          = new RemoteControlCar(speed, batteryDrain);

        car.Drive();
        car.Drive();
        Assert.True(car.BatteryDrained());
        Assert.Equal(100, car.DistanceDriven());
    }
Exemple #2
0
    public void DriveDoesNotIncreaseDistanceDrivenWhenBatteryDrained()
    {
        int speed        = 9;
        int batteryDrain = 50;
        var car          = new RemoteControlCar(speed, batteryDrain);

        // Drain the battery
        car.Drive();
        car.Drive();

        // One extra drive attempt (should not succeed)
        car.Drive();

        Assert.Equal(18, car.DistanceDriven());
    }
Exemple #3
0
    public void Distance_display_when_battery_empty()
    {
        var car = new RemoteControlCar();

        // Drain the battery
        for (var i = 0; i < 100; i++)
        {
            car.Drive();
        }

        // Attempt to drive one more time (should not work)
        car.Drive();

        Assert.Equal("Driven 2000 meters", car.DistanceDisplay());
    }
Exemple #4
0
    public void BatteryDisplayWhenBatteryEmpty()
    {
        var car = new RemoteControlCar();

        // Drain the battery
        for (var i = 0; i < 100; i++)
        {
            car.Drive();
        }

        // Attempt to drive one more time (should not work)
        car.Drive();

        Assert.Equal("Battery empty", car.BatteryDisplay());
    }
Exemple #5
0
    public void Battery_display_after_driving_once()
    {
        var car = new RemoteControlCar();

        car.Drive();
        Assert.Equal("Battery at 99%", car.BatteryDisplay());
    }
Exemple #6
0
    public void Distance_display_after_driving_once()
    {
        var car = new RemoteControlCar();

        car.Drive();
        Assert.Equal("Driven 20 meters", car.DistanceDisplay());
    }
Exemple #7
0
 public bool TryFinishTrack(RemoteControlCar car)
 {
     while (CanContinueDriving(car))
     {
         car.Drive();
     }
     return(DidCarFinishTrack(car));
 }
Exemple #8
0
    public bool CarCanFinish(RemoteControlCar car)
    {
        while (!car.BatteryDrained())
        {
            car.Drive();
        }

        return(car.DistanceDriven() >= distance);
    }
    public void Super_hungry_car_after_one_drive_is_drained()
    {
        int speed        = 100;
        int batteryDrain = 60;
        var car          = new RemoteControlCar(speed, batteryDrain);

        car.Drive();
        Assert.True(car.BatteryDrained());
    }
Exemple #10
0
    public bool TryFinishTrack(RemoteControlCar car)
    {
        while (!car.BatteryDrained() && car.DistanceDriven() < distance)
        {
            car.Drive();
        }

        return(car.DistanceDriven() >= distance);
    }
Exemple #11
0
    public void DriveIncreasesDistanceDrivenWithSpeed()
    {
        int speed        = 5;
        int batteryDrain = 1;
        var car          = new RemoteControlCar(speed, batteryDrain);

        car.Drive();

        Assert.Equal(5, car.DistanceDriven());
    }
Exemple #12
0
    public void Battery_display_after_driving_multiple_times()
    {
        var car = new RemoteControlCar();

        for (var i = 0; i < 23; i++)
        {
            car.Drive();
        }

        Assert.Equal("Battery at 77%", car.BatteryDisplay());
    }
Exemple #13
0
    public void Distance_display_after_driving_multiple_times()
    {
        var car = new RemoteControlCar();

        for (var i = 0; i < 17; i++)
        {
            car.Drive();
        }

        Assert.Equal("Driven 340 meters", car.DistanceDisplay());
    }
Exemple #14
0
 public bool CarCanFinish(RemoteControlCar car)
 {
     while (car.DistanceDriven() < Distance)
     {
         if (car.BatteryDrained())
         {
             return(false);
         }
         car.Drive();
     }
     return(true);
 }
Exemple #15
0
    public void DriveUntilBatteryIsDrained()
    {
        int speed        = 2;
        int batteryDrain = 1;
        var car          = new RemoteControlCar(speed, batteryDrain);

        // Drain the battery
        for (var i = 0; i < 100; i++)
        {
            car.Drive();
        }

        Assert.True(car.BatteryDrained());
    }
Exemple #16
0
    public void DriveToAlmostDrainBattery()
    {
        int speed        = 2;
        int batteryDrain = 1;
        var car          = new RemoteControlCar(speed, batteryDrain);

        // Almost drain the battery
        for (var i = 0; i < 99; i++)
        {
            car.Drive();
        }

        Assert.False(car.BatteryDrained());
    }