コード例 #1
0
        /// <summary>
        /// Converts a linear unit to meters.
        /// </summary>
        /// <param name="linearUnit">The LinearUnit to convert.</param>
        /// <returns>The distance in meters.</returns>
        public static Meters ToMeters(LinearUnit linearUnit)
        {
            if (linearUnit == null)
            {
                throw new ArgumentNullException("linearUnit");
            }
            Meters meters = new Meters();
            double unit   = linearUnit.ToMeters();

            return(new Meters(unit));
        }
コード例 #2
0
        public void TestName()
        {
            Meters meters = new Meters(1000);
            Miles miles = LinearUnitConverter.ToMiles(meters);
            Assertion.AssertEquals(0.62137, miles.Value,0.001);

            Kilometers km1 = LinearUnitConverter.ToKilometers(miles);
            Assertion.AssertEquals(1,km1.Value);

            Kilometers km = LinearUnitConverter.ToKilometers(meters);
            Assertion.AssertEquals(1, km.Value);
        }