コード例 #1
0
        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);
        }
コード例 #2
0
 public static FuelEfficiency KilometersPerLiters <T>(this T value) =>
 FuelEfficiency.FromKilometersPerLiters(Convert.ToDecimal(value));
コード例 #3
0
 public void NumberToKilometersPerLitersTest() =>
 Assert.Equal(FuelEfficiency.FromKilometersPerLiters(2), 2.KilometersPerLiters());