示例#1
0
    public void Buy_new_car_returns_new_car_each_time()
    {
        var car1 = RemoteControlCar.Buy();
        var car2 = RemoteControlCar.Buy();

        Assert.NotSame(car2, car1);
    }
示例#2
0
    public void GetUsagePerMeter_not_started()
    {
        var car = RemoteControlCar.Buy();
        var tc  = new TelemetryClient(car);

        Assert.Equal("no data", tc.GetBatteryUsagePerMeter(serialNum: 1));
    }
示例#3
0
    public void Top_of_the_line_car_has_correct_speed()
    {
        var car = RemoteControlCar.TopOfTheLine();

        car.Drive();
        Assert.Equal(50, car.DistanceDriven());
    }
示例#4
0
    public void Nitro_car_has_correct_speed()
    {
        var car = RemoteControlCar.Nitro();

        car.Drive();
        Assert.Equal(50, car.DistanceDriven());
    }
示例#5
0
    public void Battery_display_after_driving_once()
    {
        var car = new RemoteControlCar();

        car.Drive();
        Assert.Equal("Battery at 99%", car.BatteryDisplay());
    }
示例#6
0
    public void TopOfTheLineCarHasCorrectSpeed()
    {
        var car = RemoteControlCar.TopOfTheLine();

        car.Drive();
        Assert.Equal(50, car.DistanceDriven());
    }
示例#7
0
文件: ClassesTests.cs 项目: sgedye/v3
    public void BuyNewCarReturnsNewCarEachTime()
    {
        var car1 = RemoteControlCar.Buy();
        var car2 = RemoteControlCar.Buy();

        Assert.NotSame(car2, car1);
    }
示例#8
0
    public void Distance_display_after_driving_once()
    {
        var car = new RemoteControlCar();

        car.Drive();
        Assert.Equal("Driven 20 meters", car.DistanceDisplay());
    }
示例#9
0
    public void ShowSponsor()
    {
        var    car      = new RemoteControlCar();
        string expected = "Walker Industries Inc.";

        car.Telemetry.ShowSponsor(expected);
        Assert.Equal(expected, car.CurrentSponsor);
    }
示例#10
0
    public void ShowSpeed()
    {
        var    car      = new RemoteControlCar();
        string expected = "100 meters per second";

        car.Telemetry.SetSpeed(100, "mps");
        Assert.Equal(expected, car.GetSpeed());
    }
示例#11
0
 public bool TryFinishTrack(RemoteControlCar car)
 {
     while (CanContinueDriving(car))
     {
         car.Drive();
     }
     return(DidCarFinishTrack(car));
 }
示例#12
0
    public void NewRemoteControlCarBatteryIsNotDrained()
    {
        int speed        = 15;
        int batteryDrain = 3;
        var car          = new RemoteControlCar(speed, batteryDrain);

        Assert.False(car.BatteryDrained());
    }
示例#13
0
    public void New_remote_control_car_battery_is_not_drained()
    {
        int speed        = 15;
        int batteryDrain = 3;
        var car          = new RemoteControlCar(speed, batteryDrain);

        Assert.False(car.BatteryDrained());
    }
示例#14
0
    public void NewRemoteControlCarHasNotDrivenAnyDistance()
    {
        int speed        = 10;
        int batteryDrain = 2;
        var car          = new RemoteControlCar(speed, batteryDrain);

        Assert.Equal(0, car.DistanceDriven());
    }
示例#15
0
    public void New_remote_control_car_has_not_driven_any_distance()
    {
        int speed        = 10;
        int batteryDrain = 2;
        var car          = new RemoteControlCar(speed, batteryDrain);

        Assert.Equal(0, car.DistanceDriven());
    }
示例#16
0
    public bool CarCanFinish(RemoteControlCar car)
    {
        while (!car.BatteryDrained())
        {
            car.Drive();
        }

        return(car.DistanceDriven() >= distance);
    }
示例#17
0
    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());
    }
示例#18
0
    public void GetUsagePerMeter_good()
    {
        var car = RemoteControlCar.Buy();

        car.Drive(); car.Drive();
        var tc = new TelemetryClient(car);

        Assert.Equal("usage-per-meter=5", tc.GetBatteryUsagePerMeter(serialNum: 1));
    }
示例#19
0
    public bool TryFinishTrack(RemoteControlCar car)
    {
        while (!car.BatteryDrained() && car.DistanceDriven() < distance)
        {
            car.Drive();
        }

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

        car.Drive();

        Assert.Equal(5, car.DistanceDriven());
    }
示例#21
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());
    }
示例#22
0
    public void GetTelmetryData_good()
    {
        var car = RemoteControlCar.Buy();

        car.Drive();
        car.Drive();
        int serialNum = 1;

        car.GetTelemetryData(ref serialNum, out int batteryPercentage, out int distanceDrivenInMeters);
        Assert.Equal((1, 80, 4), (serialNum, batteryPercentage, distanceDrivenInMeters));
    }
    public void Car_can_finish_with_car_that_can_just_finish()
    {
        int speed        = 2;
        int batteryDrain = 10;
        var car          = new RemoteControlCar(speed, batteryDrain);

        int distance = 20;
        var race     = new RaceTrack(distance);

        Assert.True(race.TryFinishTrack(car));
    }
示例#24
0
    public void Car_can_finish_with_car_that_can_easily_finish()
    {
        int speed        = 10;
        int batteryDrain = 2;
        var car          = new RemoteControlCar(speed, batteryDrain);

        int distance = 100;
        var race     = new RaceTrack(distance);

        Assert.True(race.CarCanFinish(car));
    }
示例#25
0
    public void CarCanFinishWithCarThatCannotFinish()
    {
        int speed        = 1;
        int batteryDrain = 20;
        var car          = new RemoteControlCar(speed, batteryDrain);

        int distance = 678;
        var race     = new RaceTrack(distance);

        Assert.False(race.CarCanFinish(car));
    }
示例#26
0
    public void CarCanFinishWithCarThatCanJustFinish()
    {
        int speed        = 2;
        int batteryDrain = 10;
        var car          = new RemoteControlCar(speed, batteryDrain);

        int distance = 20;
        var race     = new RaceTrack(distance);

        Assert.True(race.CarCanFinish(car));
    }
示例#27
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());
    }
示例#28
0
    public void DisplayNextSponsor_for_3_sponsors()
    {
        var car = RemoteControlCar.Buy();

        car.SetSponsors("Exercism", "Walker Industries", "Acme Co.");
        var sp1 = car.DisplaySponsor(sponsorNum: 0);
        var sp2 = car.DisplaySponsor(sponsorNum: 1);
        var sp3 = car.DisplaySponsor(sponsorNum: 2);

        Assert.Equal((sp1, sp2, sp3), ("Exercism", "Walker Industries", "Acme Co."));
    }
示例#29
0
    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());
    }
示例#30
0
    public void Car_can_finish_with_car_that_just_cannot_finish()
    {
        int speed        = 3;
        int batteryDrain = 20;
        var car          = new RemoteControlCar(speed, batteryDrain);

        int distance = 16;
        var race     = new RaceTrack(distance);

        Assert.False(race.CarCanFinish(car));
    }