Esempio n. 1
0
        public void AmountCompareAutoTest()
        {
            UnitsNet.AmountOfSubstance         A1 = new UnitsNet.AmountOfSubstance(65.743, UnitsNet.Units.AmountOfSubstanceUnit.Mole);
            EngineeringUnits.AmountOfSubstance A2 = new EngineeringUnits.AmountOfSubstance(65.743, EngineeringUnits.AmountOfSubstanceUnit.Mole);

            for (int i = 0; i < UnitsNet.AmountOfSubstance.Units.Length; i++)
            {
                //Getting Units
                var EU = EngineeringUnits.AmountOfSubstanceUnit.List().ToList()[i];
                var UN = UnitsNet.AmountOfSubstance.Units[i];

                //All units absolute difference
                Assert.AreEqual(0, A2.As(EU) - A1.As(UN), 1E-5);

                //All units relative difference
                Assert.AreEqual(0, HelperClass.Percent(A2.As(EU),
                                                       A1.As(UN)),
                                1E-10);
                //All units symbol compare
                Assert.AreEqual(A2.ToUnit(EU).DisplaySymbol(),
                                A1.ToUnit(UN).ToString("a"));
            }
        }
Esempio n. 2
0
        public void AmountCompare()
        {
            UnitsNet.AmountOfSubstance         A1 = new UnitsNet.AmountOfSubstance(65.743, UnitsNet.Units.AmountOfSubstanceUnit.Mole);
            EngineeringUnits.AmountOfSubstance A2 = new EngineeringUnits.AmountOfSubstance(65.743, EngineeringUnits.AmountOfSubstanceUnit.Mole);



            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.Centimole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Centimole), 1E-10);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.CentipoundMole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.CentipoundMole), 1E-10);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.Decimole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Decimole), 0);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.DecipoundMole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.DecipoundMole), 1E-10);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.Kilomole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Kilomole), 0);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.KilopoundMole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.KilopoundMole), 1E-10);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.Megamole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Megamole), 0);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.MicropoundMole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.MicropoundMole), 1E-10);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.Micromole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Micromole), 0);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.Millimole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Millimole), 1E-10);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.MillipoundMole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.MillipoundMole), 1E-10);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.Mole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Mole), 0);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.Nanomole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Nanomole), 7.7E-06);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.NanopoundMole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.NanopoundMole), 1E-7);
            Assert.AreEqual(0, A2.As(EngineeringUnits.AmountOfSubstanceUnit.PoundMole) - A1.As(UnitsNet.Units.AmountOfSubstanceUnit.PoundMole), 1E-10);



            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromCentimoles(435).Centimoles - EngineeringUnits.AmountOfSubstance.FromCentimoles(435).Centimoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromCentipoundMoles(435).CentipoundMoles - EngineeringUnits.AmountOfSubstance.FromCentipoundMoles(435).CentipoundMoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromDecimoles(435).Decimoles - EngineeringUnits.AmountOfSubstance.FromDecimoles(435).Decimoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromDecipoundMoles(435).DecipoundMoles - EngineeringUnits.AmountOfSubstance.FromDecipoundMoles(435).DecipoundMoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromKilomoles(435).Kilomoles - EngineeringUnits.AmountOfSubstance.FromKilomoles(435).Kilomoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromKilopoundMoles(435).KilopoundMoles - EngineeringUnits.AmountOfSubstance.FromKilopoundMoles(435).KilopoundMoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromMegamoles(435).Megamoles - EngineeringUnits.AmountOfSubstance.FromMegamoles(435).Megamoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromMicromoles(435).Micromoles - EngineeringUnits.AmountOfSubstance.FromMicromoles(435).Micromoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromMicropoundMoles(435).MicropoundMoles - EngineeringUnits.AmountOfSubstance.FromMicropoundMoles(435).MicropoundMoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromMillimoles(435).Millimoles - EngineeringUnits.AmountOfSubstance.FromMillimoles(435).Millimoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromMillipoundMoles(435).MillipoundMoles - EngineeringUnits.AmountOfSubstance.FromMillipoundMoles(435).MillipoundMoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromMoles(435).Moles - EngineeringUnits.AmountOfSubstance.FromMoles(435).Moles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromNanomoles(435).Nanomoles - EngineeringUnits.AmountOfSubstance.FromNanomoles(435).Nanomoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromNanopoundMoles(435).NanopoundMoles - EngineeringUnits.AmountOfSubstance.FromNanopoundMoles(435).NanopoundMoles, 0);
            Assert.AreEqual(0, UnitsNet.AmountOfSubstance.FromPoundMoles(435).PoundMoles - EngineeringUnits.AmountOfSubstance.FromPoundMoles(435).PoundMoles, 0);


            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.Centimole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Centimole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.CentipoundMole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.CentipoundMole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.Decimole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Decimole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.DecipoundMole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.DecipoundMole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.Kilomole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Kilomole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.KilopoundMole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.KilopoundMole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.Megamole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Megamole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.Micromole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Micromole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.MicropoundMole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.MicropoundMole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.Millimole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Millimole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.MillipoundMole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.MillipoundMole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.Mole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Mole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.Nanomole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.Nanomole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.NanopoundMole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.NanopoundMole)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.AmountOfSubstanceUnit.PoundMole),
                                                   A1.As(UnitsNet.Units.AmountOfSubstanceUnit.PoundMole)), 1E-10);



            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.Centimole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.Centimole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.CentipoundMole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.CentipoundMole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.Decimole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.Decimole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.DecipoundMole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.DecipoundMole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.Kilomole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.Kilomole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.KilopoundMole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.KilopoundMole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.Megamole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.Megamole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.Micromole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.Micromole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.MicropoundMole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.MicropoundMole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.Millimole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.Millimole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.MillipoundMole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.MillipoundMole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.Mole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.Mole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.Nanomole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.Nanomole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.NanopoundMole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.NanopoundMole).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.AmountOfSubstanceUnit.PoundMole).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.AmountOfSubstanceUnit.PoundMole).ToString("a"));
        }