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 MilesPerUsGallon <T>(this T value) => FuelEfficiency.FromMilesPerUsGallon(Convert.ToDecimal(value));
public void NumberToMilesPerUsGallonTest() => Assert.Equal(FuelEfficiency.FromMilesPerUsGallon(2), 2.MilesPerUsGallon());