本文整理汇总了C#中Car.FillTank方法的典型用法代码示例。如果您正苦于以下问题:C# Car.FillTank方法的具体用法?C# Car.FillTank怎么用?C# Car.FillTank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car.FillTank方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: when_driving_car
void when_driving_car()
{
it["should throw error if car isn't started"] =
expect<InvalidOperationException>(() =>
{
Car car = new Car(tankSize: 10, mpg: 1);
car.Drive(10);
});
new[]
{
new { gasInTank = 10, mpg = 1, miles = 10.0, expectedDistance = 10.0,
gasLeft = 0.0, running = false, lowfuel = true, onEmpty = true },
new { gasInTank = 10, mpg = 2, miles = 5.0, expectedDistance = 5.0,
gasLeft = 7.5, running = true, lowfuel = false, onEmpty = false },
new { gasInTank = 10, mpg = 10, miles = 10.0, expectedDistance = 10.0,
gasLeft = 9.0, running = true, lowfuel = false, onEmpty = false }
}.Do(example =>
{
context["with {0} gallon(s) of gas, mpg: {1}, driving: {2} miles"
.With(example.gasInTank, example.mpg, example.miles)] = () =>
{
Car car = null;
before = () =>
{
car = new Car(example.gasInTank, example.mpg);
car.FillTank(example.gasInTank);
};
act = () => car.Drive(example.miles);
it["should have made it {0} miles".With(example.expectedDistance)] = () =>
{
car.Odometer.should_be(example.expectedDistance);
};
it["should have {0} gallons left in tank".With(example.gasLeft)] = () =>
{
car.GasInTank.should_be(example.gasLeft);
};
it["should {0} running".With(example.running ? "be" : "not be")] = () =>
{
car.IsRunning.should_be(example.running);
};
it["should {0} low fuel".With(example.lowfuel ? "have" : "not have")] = () =>
{
car.IsLowOnFuel.should_be(example.lowfuel);
};
};
});
}