Beispiel #1
0
        public void MeasurementConversionsValidInput()
        {
            //feet tests
            Assert.AreEqual("1' 3\"", Foot.ToDisplayString(1.25, DynamoUnitDisplayType.FractionalFeetInches));
            Assert.AreEqual("15\"", Foot.ToDisplayString(1.25, DynamoUnitDisplayType.FractionalInches));
            Assert.AreEqual("1' 3\"", Utils.ToFeetAndFractionalInches(1.25));
            Assert.AreEqual("15\"", Utils.ToFractionalInches(1.25 * 12));
            Assert.AreEqual(1.25, Foot.FromDisplayString("1' 3\"", DynamoUnitDisplayType.FractionalFeetInches));
            Assert.AreEqual("1' 2\"", Foot.ToDisplayString(1.16667, DynamoUnitDisplayType.FractionalFeetInches));
            Assert.AreEqual("1' 2\"", Utils.ToFeetAndFractionalInches(1.16667));

            //inch tests
            Assert.AreEqual(string.Format("{0} cm", (30.48).ToString(CultureInfo.CurrentCulture)), Inch.ToDisplayString(12.0, DynamoUnitDisplayType.Centimeters));
            Assert.AreEqual(string.Format("{0} ft", (1.0).ToString("0.00", CultureInfo.CurrentCulture)), Inch.ToDisplayString(12.0, DynamoUnitDisplayType.DecimalFeet));
            Assert.AreEqual(string.Format("{0} in", (12.00).ToString("0.00", CultureInfo.CurrentCulture)), Inch.ToDisplayString(12.0, DynamoUnitDisplayType.DecimalInches));
            Assert.AreEqual("1' 0\"", Inch.ToDisplayString(12.0, DynamoUnitDisplayType.FractionalFeetInches));
            Assert.AreEqual("12\"", Inch.ToDisplayString(12.0, DynamoUnitDisplayType.FractionalInches));
            Assert.AreEqual(string.Format("{0} m", (0.30).ToString("0.00", CultureInfo.CurrentCulture)), Inch.ToDisplayString(12.0, DynamoUnitDisplayType.Meters));
            Assert.AreEqual(string.Format("{0} mm", (304.80).ToString("0.00", CultureInfo.CurrentCulture)), Inch.ToDisplayString(12.0, DynamoUnitDisplayType.Millimeters));
            Assert.AreEqual(14.5, Inch.FromDisplayString("1' 2 1/2\"", DynamoUnitDisplayType.FractionalInches), 0.0001);
            Assert.AreEqual(14.5, Inch.FromDisplayString("14 1/2\"", DynamoUnitDisplayType.FractionalInches), 0.0001);
        }