Ejemplo n.º 1
0
        public void EqualsIsImplemented()
        {
            MolarMass v = MolarMass.FromKilogramsPerMole(1);

            Assert.True(v.Equals(MolarMass.FromKilogramsPerMole(1), MolarMass.FromKilogramsPerMole(KilogramsPerMoleTolerance)));
            Assert.False(v.Equals(MolarMass.Zero, MolarMass.FromKilogramsPerMole(KilogramsPerMoleTolerance)));
        }
Ejemplo n.º 2
0
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = MolarMass.FromKilogramsPerMole(1);

            Assert.True(v.Equals(MolarMass.FromKilogramsPerMole(1), KilogramsPerMoleTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(MolarMass.Zero, KilogramsPerMoleTolerance, ComparisonType.Relative));
        }
Ejemplo n.º 3
0
        public void CompareToIsImplemented()
        {
            MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            Assert.Equal(0, kilogrampermole.CompareTo(kilogrampermole));
            Assert.True(kilogrampermole.CompareTo(MolarMass.Zero) > 0);
            Assert.True(MolarMass.Zero.CompareTo(kilogrampermole) < 0);
        }
Ejemplo n.º 4
0
        public void Equals_SameType_IsImplemented()
        {
            var a = MolarMass.FromKilogramsPerMole(1);
            var b = MolarMass.FromKilogramsPerMole(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
        public void FromKilogramsPerMole_WithInfinityValue_CreateQuantityAndAffectInfinityValue()
        {
            var positiveInfinityQuantity = MolarMass.FromKilogramsPerMole(double.PositiveInfinity);
            var negativeInfinityQuantity = MolarMass.FromKilogramsPerMole(double.NegativeInfinity);

            Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value));
            Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value));
        }
Ejemplo n.º 6
0
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = MolarMass.FromKilogramsPerMole(1);
            object b = MolarMass.FromKilogramsPerMole(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
Ejemplo n.º 7
0
 public MolarMass molar_mass()
 {
     if (Environment.Is64BitProcess)
     {
         return(MolarMass.FromKilogramsPerMole(CoolPropPINVOKE64.AbstractState_molar_mass(swigCPtr)));
     }
     else
     {
         return(MolarMass.FromKilogramsPerMole(CoolPropPINVOKE.AbstractState_molar_mass(swigCPtr)));
     }
 }
Ejemplo n.º 8
0
        public void ArithmeticOperators()
        {
            MolarMass v = MolarMass.FromKilogramsPerMole(1);

            AssertEx.EqualTolerance(-1, -v.KilogramsPerMole, KilogramsPerMoleTolerance);
            AssertEx.EqualTolerance(2, (MolarMass.FromKilogramsPerMole(3) - v).KilogramsPerMole, KilogramsPerMoleTolerance);
            AssertEx.EqualTolerance(2, (v + v).KilogramsPerMole, KilogramsPerMoleTolerance);
            AssertEx.EqualTolerance(10, (v * 10).KilogramsPerMole, KilogramsPerMoleTolerance);
            AssertEx.EqualTolerance(10, (10 * v).KilogramsPerMole, KilogramsPerMoleTolerance);
            AssertEx.EqualTolerance(2, (MolarMass.FromKilogramsPerMole(10) / 5).KilogramsPerMole, KilogramsPerMoleTolerance);
            AssertEx.EqualTolerance(2, MolarMass.FromKilogramsPerMole(10) / MolarMass.FromKilogramsPerMole(5), KilogramsPerMoleTolerance);
        }
Ejemplo n.º 9
0
        public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
        {
            var kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            Assert.Throws <ArgumentException>(() => kilogrampermole.ToUnit(UnitSystem.SI));
            Assert.Throws <ArgumentException>(() => kilogrampermole.ToUnit(UnitSystem.CGS));
            Assert.Throws <ArgumentException>(() => kilogrampermole.ToUnit(UnitSystem.BI));
            Assert.Throws <ArgumentException>(() => kilogrampermole.ToUnit(UnitSystem.EE));
            Assert.Throws <ArgumentException>(() => kilogrampermole.ToUnit(UnitSystem.USC));
            Assert.Throws <ArgumentException>(() => kilogrampermole.ToUnit(UnitSystem.FPS));
            Assert.Throws <ArgumentException>(() => kilogrampermole.ToUnit(UnitSystem.Astronomical));
        }
Ejemplo n.º 10
0
        public void EqualityOperators()
        {
            MolarMass a = MolarMass.FromKilogramsPerMole(1);
            MolarMass b = MolarMass.FromKilogramsPerMole(2);

// ReSharper disable EqualExpressionComparison
            Assert.True(a == a);
            Assert.True(a != b);

            Assert.False(a == b);
            Assert.False(a != a);
// ReSharper restore EqualExpressionComparison
        }
Ejemplo n.º 11
0
        public void ComparisonOperators()
        {
            MolarMass oneKilogramPerMole  = MolarMass.FromKilogramsPerMole(1);
            MolarMass twoKilogramsPerMole = MolarMass.FromKilogramsPerMole(2);

            Assert.True(oneKilogramPerMole < twoKilogramsPerMole);
            Assert.True(oneKilogramPerMole <= twoKilogramsPerMole);
            Assert.True(twoKilogramsPerMole > oneKilogramPerMole);
            Assert.True(twoKilogramsPerMole >= oneKilogramPerMole);

            Assert.False(oneKilogramPerMole > twoKilogramsPerMole);
            Assert.False(oneKilogramPerMole >= twoKilogramsPerMole);
            Assert.False(twoKilogramsPerMole < oneKilogramPerMole);
            Assert.False(twoKilogramsPerMole <= oneKilogramPerMole);
        }
Ejemplo n.º 12
0
        public void ConversionRoundTrip()
        {
            MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            AssertEx.EqualTolerance(1, MolarMass.FromCentigramsPerMole(kilogrampermole.CentigramsPerMole).KilogramsPerMole, CentigramsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromDecagramsPerMole(kilogrampermole.DecagramsPerMole).KilogramsPerMole, DecagramsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromDecigramsPerMole(kilogrampermole.DecigramsPerMole).KilogramsPerMole, DecigramsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromGramsPerMole(kilogrampermole.GramsPerMole).KilogramsPerMole, GramsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromHectogramsPerMole(kilogrampermole.HectogramsPerMole).KilogramsPerMole, HectogramsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromKilogramsPerMole(kilogrampermole.KilogramsPerMole).KilogramsPerMole, KilogramsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromKilopoundsPerMole(kilogrampermole.KilopoundsPerMole).KilogramsPerMole, KilopoundsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromMegapoundsPerMole(kilogrampermole.MegapoundsPerMole).KilogramsPerMole, MegapoundsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromMicrogramsPerMole(kilogrampermole.MicrogramsPerMole).KilogramsPerMole, MicrogramsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromMilligramsPerMole(kilogrampermole.MilligramsPerMole).KilogramsPerMole, MilligramsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromNanogramsPerMole(kilogrampermole.NanogramsPerMole).KilogramsPerMole, NanogramsPerMoleTolerance);
            AssertEx.EqualTolerance(1, MolarMass.FromPoundsPerMole(kilogrampermole.PoundsPerMole).KilogramsPerMole, PoundsPerMoleTolerance);
        }
Ejemplo n.º 13
0
        public void KilogramPerMoleToMolarMassUnits()
        {
            MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            AssertEx.EqualTolerance(CentigramsPerMoleInOneKilogramPerMole, kilogrampermole.CentigramsPerMole, CentigramsPerMoleTolerance);
            AssertEx.EqualTolerance(DecagramsPerMoleInOneKilogramPerMole, kilogrampermole.DecagramsPerMole, DecagramsPerMoleTolerance);
            AssertEx.EqualTolerance(DecigramsPerMoleInOneKilogramPerMole, kilogrampermole.DecigramsPerMole, DecigramsPerMoleTolerance);
            AssertEx.EqualTolerance(GramsPerMoleInOneKilogramPerMole, kilogrampermole.GramsPerMole, GramsPerMoleTolerance);
            AssertEx.EqualTolerance(HectogramsPerMoleInOneKilogramPerMole, kilogrampermole.HectogramsPerMole, HectogramsPerMoleTolerance);
            AssertEx.EqualTolerance(KilogramsPerMoleInOneKilogramPerMole, kilogrampermole.KilogramsPerMole, KilogramsPerMoleTolerance);
            AssertEx.EqualTolerance(KilopoundsPerMoleInOneKilogramPerMole, kilogrampermole.KilopoundsPerMole, KilopoundsPerMoleTolerance);
            AssertEx.EqualTolerance(MegapoundsPerMoleInOneKilogramPerMole, kilogrampermole.MegapoundsPerMole, MegapoundsPerMoleTolerance);
            AssertEx.EqualTolerance(MicrogramsPerMoleInOneKilogramPerMole, kilogrampermole.MicrogramsPerMole, MicrogramsPerMoleTolerance);
            AssertEx.EqualTolerance(MilligramsPerMoleInOneKilogramPerMole, kilogrampermole.MilligramsPerMole, MilligramsPerMoleTolerance);
            AssertEx.EqualTolerance(NanogramsPerMoleInOneKilogramPerMole, kilogrampermole.NanogramsPerMole, NanogramsPerMoleTolerance);
            AssertEx.EqualTolerance(PoundsPerMoleInOneKilogramPerMole, kilogrampermole.PoundsPerMole, PoundsPerMoleTolerance);
        }
Ejemplo n.º 14
0
        public void As()
        {
            var kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            AssertEx.EqualTolerance(CentigramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.CentigramPerMole), CentigramsPerMoleTolerance);
            AssertEx.EqualTolerance(DecagramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.DecagramPerMole), DecagramsPerMoleTolerance);
            AssertEx.EqualTolerance(DecigramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.DecigramPerMole), DecigramsPerMoleTolerance);
            AssertEx.EqualTolerance(GramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.GramPerMole), GramsPerMoleTolerance);
            AssertEx.EqualTolerance(HectogramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.HectogramPerMole), HectogramsPerMoleTolerance);
            AssertEx.EqualTolerance(KilogramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.KilogramPerMole), KilogramsPerMoleTolerance);
            AssertEx.EqualTolerance(KilopoundsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.KilopoundPerMole), KilopoundsPerMoleTolerance);
            AssertEx.EqualTolerance(MegapoundsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.MegapoundPerMole), MegapoundsPerMoleTolerance);
            AssertEx.EqualTolerance(MicrogramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.MicrogramPerMole), MicrogramsPerMoleTolerance);
            AssertEx.EqualTolerance(MilligramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.MilligramPerMole), MilligramsPerMoleTolerance);
            AssertEx.EqualTolerance(NanogramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.NanogramPerMole), NanogramsPerMoleTolerance);
            AssertEx.EqualTolerance(PoundsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.PoundPerMole), PoundsPerMoleTolerance);
        }
Ejemplo n.º 15
0
        public void EqualityOperators()
        {
            var a = MolarMass.FromKilogramsPerMole(1);
            var b = MolarMass.FromKilogramsPerMole(2);

#pragma warning disable CS8073
// ReSharper disable EqualExpressionComparison

            Assert.True(a == a);
            Assert.False(a != a);

            Assert.True(a != b);
            Assert.False(a == b);

            Assert.False(a == null);
            Assert.False(null == a);

// ReSharper restore EqualExpressionComparison
#pragma warning restore CS8073
        }
Ejemplo n.º 16
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

            Assert.Equal(MolarMass.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Ejemplo n.º 17
0
        public void CompareToThrowsOnNull()
        {
            MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            Assert.Throws <ArgumentNullException>(() => kilogrampermole.CompareTo(null));
        }
Ejemplo n.º 18
0
        public void CompareToThrowsOnTypeMismatch()
        {
            MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            Assert.Throws <ArgumentException>(() => kilogrampermole.CompareTo(new object()));
        }
Ejemplo n.º 19
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Ejemplo n.º 20
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Ejemplo n.º 21
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = MolarMass.FromKilogramsPerMole(value);

            Assert.Equal(MolarMass.FromKilogramsPerMole(-value), -quantity);
        }
Ejemplo n.º 22
0
        public void EqualsReturnsFalseOnNull()
        {
            MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            Assert.False(kilogrampermole.Equals(null));
        }
Ejemplo n.º 23
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Ejemplo n.º 24
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

            Assert.Equal(QuantityType.MolarMass, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Ejemplo n.º 25
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarMassUnit)));
        }
Ejemplo n.º 26
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(MolarMass)));
        }
Ejemplo n.º 27
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            Assert.False(kilogrampermole.Equals(new object()));
        }
Ejemplo n.º 28
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Ejemplo n.º 29
0
 public void NumberToKilogramsPerMoleTest() =>
 Assert.Equal(MolarMass.FromKilogramsPerMole(2), 2.KilogramsPerMole());
Ejemplo n.º 30
0
        public void GetHashCode_Equals()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

            Assert.Equal(new { MolarMass.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }