public void ShouldConvertExponentToInternationalSystemPrefix( [Values("Y", "Z", "E", "P", "T", "G", "M", "k", "h", "da", "", "d", "c", "m", "µ", "n", "p", "f", "a", "z", "y")] string prefix, [Values(24, 21, 18, 15, 12, 9, 6, 3, 2, 1, 0, -1, -2, -3, -6, -9, -12, -15, -18, -21, -24)] int exponent) { var siUnits = new InternationalSystem(); Assert.That(siUnits.ToPrefix(exponent), Is.EqualTo(prefix)); }
public void ShouldHandleScalingInBaseUnitIdentityConversion( [Values(-3, -2, -1, 0, 1, 2, 3)] int toExp, [Values(-3, -2, -1, 0, 1, 2, 3)] int fromExp) { var q = 1.5m; var m = new Measurement(q, fromExp, "B"); var siUnits = new InternationalSystem(); Assert.That(Converters.Convert(m, string.Format("{0}{1}", siUnits.ToPrefix(toExp), "B")), Is.EqualTo(new Measurement(q * (decimal)Math.Pow(10, fromExp - toExp), toExp, "B"))); }