Beispiel #1
0
        public void ElectriccurrentCompareAutoTest()
        {
            UnitsNet.ElectricCurrent         A1 = new UnitsNet.ElectricCurrent(65.743, UnitsNet.Units.ElectricCurrentUnit.Ampere);
            EngineeringUnits.ElectricCurrent A2 = new EngineeringUnits.ElectricCurrent(65.743, EngineeringUnits.ElectricCurrentUnit.Ampere);

            for (int i = 0; i < UnitsNet.ElectricCurrent.Units.Length; i++)
            {
                //Getting Units
                var EU = EngineeringUnits.ElectricCurrentUnit.List().ToList()[i];
                var UN = UnitsNet.ElectricCurrent.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"));
            }
        }
Beispiel #2
0
        public void ElectriccurrentCompare()
        {
            UnitsNet.ElectricCurrent         A1 = new UnitsNet.ElectricCurrent(0.0000546, UnitsNet.Units.ElectricCurrentUnit.Ampere);
            EngineeringUnits.ElectricCurrent A2 = new EngineeringUnits.ElectricCurrent(0.0000546, EngineeringUnits.ElectricCurrentUnit.Ampere);



            Assert.AreEqual(0, A2.As(EngineeringUnits.ElectricCurrentUnit.Ampere) - A1.As(UnitsNet.Units.ElectricCurrentUnit.Ampere), 0);
            Assert.AreEqual(0, A2.As(EngineeringUnits.ElectricCurrentUnit.Centiampere) - A1.As(UnitsNet.Units.ElectricCurrentUnit.Centiampere), 0);
            Assert.AreEqual(0, A2.As(EngineeringUnits.ElectricCurrentUnit.Kiloampere) - A1.As(UnitsNet.Units.ElectricCurrentUnit.Kiloampere), 0);
            Assert.AreEqual(0, A2.As(EngineeringUnits.ElectricCurrentUnit.Megaampere) - A1.As(UnitsNet.Units.ElectricCurrentUnit.Megaampere), 0);
            Assert.AreEqual(0, A2.As(EngineeringUnits.ElectricCurrentUnit.Microampere) - A1.As(UnitsNet.Units.ElectricCurrentUnit.Microampere), 0);
            Assert.AreEqual(0, A2.As(EngineeringUnits.ElectricCurrentUnit.Milliampere) - A1.As(UnitsNet.Units.ElectricCurrentUnit.Milliampere), 7E-18);
            Assert.AreEqual(0, A2.As(EngineeringUnits.ElectricCurrentUnit.Nanoampere) - A1.As(UnitsNet.Units.ElectricCurrentUnit.Nanoampere), 7.3E-12);
            Assert.AreEqual(0, A2.As(EngineeringUnits.ElectricCurrentUnit.Picoampere) - A1.As(UnitsNet.Units.ElectricCurrentUnit.Picoampere), 0);



            Assert.AreEqual(0, UnitsNet.ElectricCurrent.FromAmperes(435).Amperes - EngineeringUnits.ElectricCurrent.FromAmperes(435).Amperes, 0);
            Assert.AreEqual(0, UnitsNet.ElectricCurrent.FromCentiamperes(435).Centiamperes - EngineeringUnits.ElectricCurrent.FromCentiamperes(435).Centiamperes, 0);
            Assert.AreEqual(0, UnitsNet.ElectricCurrent.FromKiloamperes(435).Kiloamperes - EngineeringUnits.ElectricCurrent.FromKiloamperes(435).Kiloamperes, 0);
            Assert.AreEqual(0, UnitsNet.ElectricCurrent.FromMegaamperes(435).Megaamperes - EngineeringUnits.ElectricCurrent.FromMegaamperes(435).Megaamperes, 0);
            Assert.AreEqual(0, UnitsNet.ElectricCurrent.FromMicroamperes(435).Microamperes - EngineeringUnits.ElectricCurrent.FromMicroamperes(435).Microamperes, 0);
            Assert.AreEqual(0, UnitsNet.ElectricCurrent.FromMilliamperes(435).Milliamperes - EngineeringUnits.ElectricCurrent.FromMilliamperes(435).Milliamperes, 0);
            Assert.AreEqual(0, UnitsNet.ElectricCurrent.FromNanoamperes(435).Nanoamperes - EngineeringUnits.ElectricCurrent.FromNanoamperes(435).Nanoamperes, 0);
            Assert.AreEqual(0, UnitsNet.ElectricCurrent.FromPicoamperes(435).Picoamperes - EngineeringUnits.ElectricCurrent.FromPicoamperes(435).Picoamperes, 0);


            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.ElectricCurrentUnit.Ampere),
                                                   A1.As(UnitsNet.Units.ElectricCurrentUnit.Ampere)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.ElectricCurrentUnit.Centiampere),
                                                   A1.As(UnitsNet.Units.ElectricCurrentUnit.Centiampere)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.ElectricCurrentUnit.Kiloampere),
                                                   A1.As(UnitsNet.Units.ElectricCurrentUnit.Kiloampere)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.ElectricCurrentUnit.Megaampere),
                                                   A1.As(UnitsNet.Units.ElectricCurrentUnit.Megaampere)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.ElectricCurrentUnit.Microampere),
                                                   A1.As(UnitsNet.Units.ElectricCurrentUnit.Microampere)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.ElectricCurrentUnit.Milliampere),
                                                   A1.As(UnitsNet.Units.ElectricCurrentUnit.Milliampere)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.ElectricCurrentUnit.Nanoampere),
                                                   A1.As(UnitsNet.Units.ElectricCurrentUnit.Nanoampere)), 1E-10);
            Assert.AreEqual(0, HelperClass.Percent(A2.As(EngineeringUnits.ElectricCurrentUnit.Picoampere),
                                                   A1.As(UnitsNet.Units.ElectricCurrentUnit.Picoampere)), 1E-10);

            Assert.AreEqual(A2.ToUnit(EngineeringUnits.ElectricCurrentUnit.Ampere).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.ElectricCurrentUnit.Ampere).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.ElectricCurrentUnit.Centiampere).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.ElectricCurrentUnit.Centiampere).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.ElectricCurrentUnit.Kiloampere).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.ElectricCurrentUnit.Kiloampere).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.ElectricCurrentUnit.Megaampere).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.ElectricCurrentUnit.Megaampere).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.ElectricCurrentUnit.Microampere).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.ElectricCurrentUnit.Microampere).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.ElectricCurrentUnit.Milliampere).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.ElectricCurrentUnit.Milliampere).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.ElectricCurrentUnit.Nanoampere).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.ElectricCurrentUnit.Nanoampere).ToString("a"));
            Assert.AreEqual(A2.ToUnit(EngineeringUnits.ElectricCurrentUnit.Picoampere).DisplaySymbol(),
                            A1.ToUnit(UnitsNet.Units.ElectricCurrentUnit.Picoampere).ToString("a"));
        }