示例#1
0
        public void DerivedUnitFromSiValueTest()
        {
            var metersPerSecond = Units.MetersPerSecond;
            var milesPerHour    = new Unit("mph", Units.Miles / Units.Hours);

            (10.0 * metersPerSecond).ValueInUnits(milesPerHour).Should().BeApproximately(22.3694, 0.0001);
        }
示例#2
0
        public void DocumentationExample()
        {
            var cookieCount = new Dimension("Cookie Count");
            var cookieRate  = new Dimension("Cookie Rate", cookieCount / Dimensions.Time);

            var cookies      = cookieCount.NewSiUnit("cookies");
            var dozenCookies = new Unit("dz", 12 * cookies);
            var grossCookies = new Unit("gr", 144 * cookies);

            var workWeek = new Unit("work week", 40 * Units.Hours);

            var totalCookies = 12 * grossCookies;
            var cookiesRate  = totalCookies / workWeek;

            cookiesRate.ToString("{0:0.000} {1}").Should().Be("0.012 cookies/s");
            cookiesRate.ToString(cookies / Units.Minutes).Should().Be("0.72 cookies/min");
            cookiesRate.ToString("{0:0.0} {1}", dozenCookies / Units.Hours).Should().Be("3.6 dz/hr");
        }
示例#3
0
 public Unit NewSiUnit(string name)
 {
     _defaultUnit = new Unit(name, this);
     return(_defaultUnit);
 }
示例#4
0
 private Dimension(RationalCombination <Dimension> combinable)
 {
     _baseDimensions = combinable;
     _defaultUnit    = null;
 }
示例#5
0
 private static Unit Add(Unit unit)
 {
     PredefinedUnits.Add(unit);
     return(unit);
 }
示例#6
0
        public void DerivedUnitToSiValueTest()
        {
            var milesPerHour = new Unit("mph", Units.Miles / Units.Hours);

            (60.0 * milesPerHour).ValueInSiUnits.Should().BeApproximately(26.8224, 0.0001);
        }