public void ImplicitToLength() { var typographicLength = 5 * TypographicLength.Inch; Length length = typographicLength; Assert.That(length, QuantityIs.EqualTo(5 * Length.Inch).Within(1e-6)); }
public void ImplicitFromLength() { var length = 5 * Length.Inch; TypographicLength typographicLength = length; Assert.That(typographicLength, QuantityIs.EqualTo(5 * TypographicLength.Inch).Within(1e-6)); }
public void VelocityMultipliedByVelocity() { var mySpeed = 100 * Velocity.KilometrePerHour; Assert.That((mySpeed * Velocity.KilometrePerHour).ToString("0.00", CultureInfo.InvariantCulture), Is.EqualTo("7.72 m^2/s^2")); Assert.That(mySpeed * Velocity.KilometrePerHour, QuantityIs.EqualTo(100 / 3.6 / 3.6 * VelocitySquared.MetreSquaredPerSecondSquared).Within(1e-8)); mySpeed = 100 * Velocity.MetrePerSecond; Assert.That(mySpeed * Velocity.KilometrePerHour, QuantityIs.EqualTo(100 / 3.6 * VelocitySquared.MetreSquaredPerSecondSquared).Within(1e-8)); Assert.That((mySpeed * Velocity.KilometrePerHour).ToString("0.00", CultureInfo.InvariantCulture), Is.EqualTo("27.78 m^2/s^2")); }
public void Operators() { var resolution = 300 * TypographicResolution.DotsPerInch; var typographicLength = 5 * TypographicLength.Inch; var length = 5 * Length.Inch; Assert.That(typographicLength * resolution, Is.EqualTo(1500).Within(1e-6)); Assert.That(resolution * typographicLength, Is.EqualTo(1500).Within(1e-6)); Assert.That(length * resolution, Is.EqualTo(1500).Within(1e-6)); Assert.That(resolution * length, Is.EqualTo(1500).Within(1e-6)); Assert.That(1500d / (5 * TypographicLength.Inch), QuantityIs.EqualTo(300 * TypographicResolution.DotsPerInch).Within(1e-6 * TypographicResolution.DotsPerInch)); Assert.That(1500d / (5 * Length.Inch), QuantityIs.EqualTo(300 * TypographicResolution.DotsPerInch).Within(1e-6 * TypographicResolution.DotsPerInch)); Assert.That(1500d / (300 * TypographicResolution.DotsPerInch), QuantityIs.EqualTo(5 * TypographicLength.Inch).Within(1e-6 * TypographicLength.Inch)); }
protected static void AssertAreEqual <T>(T expected, T actual, T tolerance, string message = null) where T : IQuantity { Assert.That(actual, QuantityIs.EqualTo(expected).Within(tolerance), message); }