public void ConversionRoundTrip() { FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); AssertEx.EqualTolerance(1, FuelEfficiency.FromKilometersPerLiters(literper100kilometers.KilometersPerLiters).LitersPer100Kilometers, KilometersPerLitersTolerance); AssertEx.EqualTolerance(1, FuelEfficiency.FromLitersPer100Kilometers(literper100kilometers.LitersPer100Kilometers).LitersPer100Kilometers, LitersPer100KilometersTolerance); AssertEx.EqualTolerance(1, FuelEfficiency.FromMilesPerUkGallon(literper100kilometers.MilesPerUkGallon).LitersPer100Kilometers, MilesPerUkGallonTolerance); AssertEx.EqualTolerance(1, FuelEfficiency.FromMilesPerUsGallon(literper100kilometers.MilesPerUsGallon).LitersPer100Kilometers, MilesPerUsGallonTolerance); }
public static FuelEfficiency KilometersPerLiters <T>(this T value) => FuelEfficiency.FromKilometersPerLiters(Convert.ToDecimal(value));
public void NumberToKilometersPerLitersTest() => Assert.Equal(FuelEfficiency.FromKilometersPerLiters(2), 2.KilometersPerLiters());