コード例 #1
0
        public void PathToUnitTest()
        {
            double expected = 63360;

            Mile mil = new Mile();
            Inch i   = new Inch();

            UnitPathStack actual = mil.PathToUnit(i);

            Assert.AreEqual(expected, actual.ConversionFactor);


            Gram g = new Gram();

            g.UnitPrefix = MetricPrefix.None;

            Gram Mg = new Gram();

            Mg.UnitPrefix = MetricPrefix.Mega;

            actual = g.PathToUnit(Mg);

            Assert.AreEqual(1e-6, actual.ConversionFactor);


            Metre mr = new Metre();

            actual = i.PathToUnit(mr);

            Assert.AreEqual(0.0254, actual.ConversionFactor);

            //now the idea is to make any combination of units to go to any combination of units
            QuantityDimension qd = QuantityDimension.ParseMLT("M1L0T-1");
            Unit u = Unit.DiscoverUnit(qd);

            Assert.AreEqual("<kg/s>", u.Symbol);
            Assert.AreEqual(qd, u.UnitDimension);
        }