Beispiel #1
0
        public void CreateAndConvertFeetValidInput()
        {
            //test positive cases
            var mm = Foot.ConvertTo(1.3177, DynamoUnitType.Millimeters);

            Assert.AreEqual(304.8 * 1.3177, mm, 0.001);

            var cm = Foot.ConvertTo(1.3177, DynamoUnitType.Centimeters);

            Assert.AreEqual(30.48 * 1.3177, cm, 0.001);

            var m = Foot.ConvertTo(1.3177, DynamoUnitType.Meters);

            Assert.AreEqual(.3048 * 1.3177, m, 0.001);

            var inch = Foot.ConvertTo(1.3177, DynamoUnitType.Inches);

            Assert.AreEqual(12.0 * 1.3177, inch, 0.001);

            var ft = Foot.ConvertTo(1.3177, DynamoUnitType.Feet);

            Assert.AreEqual(1.0 * 1.3177, ft, 0.001);

            Assert.AreEqual("1' 3 13/16\"", Foot.AsString(1.3177));

            mm = Foot.ConvertTo(-1.3177, DynamoUnitType.Millimeters);
            Assert.AreEqual(-304.8 * 1.3177, mm, 0.001);

            cm = Foot.ConvertTo(-1.3177, DynamoUnitType.Centimeters);
            Assert.AreEqual(-30.48 * 1.3177, cm, 0.001);

            m = Foot.ConvertTo(-1.3177, DynamoUnitType.Meters);
            Assert.AreEqual(-.3048 * 1.3177, m, 0.001);

            inch = Foot.ConvertTo(-1.3177, DynamoUnitType.Inches);
            Assert.AreEqual(-12.0 * 1.3177, inch, 0.001);

            ft = Foot.ConvertTo(-1.3177, DynamoUnitType.Feet);
            Assert.AreEqual(-1.0 * 1.3177, ft, 0.001);

            //Assert.AreEqual("-1' 3 13/16\"", ftLength.ToString());

            //test just the fractional case
            Assert.AreEqual("3\"", Foot.AsString(.25));
            Assert.AreEqual("-3\"", Foot.AsString(-.25));

            //test just the whole case
            Assert.AreEqual("1' 0\"", Foot.AsString(1.0));
            Assert.AreEqual("-1' 0\"", Foot.AsString(-1.0));

            //test some edge cases
            Assert.AreEqual("0' 0\"", Foot.AsString(0.0));
            Assert.AreEqual("1/8\"", Foot.AsString(0.01));
            Assert.AreEqual("11 57/64\"", Foot.AsString(0.99));
            Assert.AreEqual("1'", Foot.AsString(0.999));
        }