예제 #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)));
        }
예제 #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));
        }
예제 #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);
        }
예제 #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));
        }
예제 #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));
        }
예제 #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)));
     }
 }
예제 #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);
        }
예제 #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));
        }
예제 #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
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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
        }
예제 #16
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

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

            Assert.Throws <ArgumentNullException>(() => kilogrampermole.CompareTo(null));
        }
예제 #18
0
        public void CompareToThrowsOnTypeMismatch()
        {
            MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1);

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

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

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
예제 #21
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = MolarMass.FromKilogramsPerMole(value);

            Assert.Equal(MolarMass.FromKilogramsPerMole(-value), -quantity);
        }
예제 #22
0
        public void EqualsReturnsFalseOnNull()
        {
            MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            Assert.False(kilogrampermole.Equals(null));
        }
예제 #23
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

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

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

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

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(MolarMass)));
        }
예제 #27
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1);

            Assert.False(kilogrampermole.Equals(new object()));
        }
예제 #28
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = MolarMass.FromKilogramsPerMole(1.0);

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

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