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); }
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"); }
public Unit NewSiUnit(string name) { _defaultUnit = new Unit(name, this); return(_defaultUnit); }
private Dimension(RationalCombination <Dimension> combinable) { _baseDimensions = combinable; _defaultUnit = null; }
private static Unit Add(Unit unit) { PredefinedUnits.Add(unit); return(unit); }
public void DerivedUnitToSiValueTest() { var milesPerHour = new Unit("mph", Units.Miles / Units.Hours); (60.0 * milesPerHour).ValueInSiUnits.Should().BeApproximately(26.8224, 0.0001); }