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))); }
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)); }
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); }
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)); }
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)); }
public MolarMass molar_mass() { if (Environment.Is64BitProcess) { return(MolarMass.FromKilogramsPerMole(CoolPropPINVOKE64.AbstractState_molar_mass(swigCPtr))); } else { return(MolarMass.FromKilogramsPerMole(CoolPropPINVOKE.AbstractState_molar_mass(swigCPtr))); } }
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); }
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)); }
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 }
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); }
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); }
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); }
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); }
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 }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = MolarMass.FromKilogramsPerMole(1.0); Assert.Equal(MolarMass.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void CompareToThrowsOnNull() { MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); Assert.Throws <ArgumentNullException>(() => kilogrampermole.CompareTo(null)); }
public void CompareToThrowsOnTypeMismatch() { MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); Assert.Throws <ArgumentException>(() => kilogrampermole.CompareTo(new object())); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = MolarMass.FromKilogramsPerMole(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void Convert_ToString_EqualsToString() { var quantity = MolarMass.FromKilogramsPerMole(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = MolarMass.FromKilogramsPerMole(value); Assert.Equal(MolarMass.FromKilogramsPerMole(-value), -quantity); }
public void EqualsReturnsFalseOnNull() { MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); Assert.False(kilogrampermole.Equals(null)); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = MolarMass.FromKilogramsPerMole(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = MolarMass.FromKilogramsPerMole(1.0); Assert.Equal(QuantityType.MolarMass, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = MolarMass.FromKilogramsPerMole(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarMassUnit))); }
public void Convert_ChangeType_SelfType_EqualsSelf() { var quantity = MolarMass.FromKilogramsPerMole(1.0); Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(MolarMass))); }
public void EqualsReturnsFalseOnTypeMismatch() { MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); Assert.False(kilogrampermole.Equals(new object())); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = MolarMass.FromKilogramsPerMole(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void NumberToKilogramsPerMoleTest() => Assert.Equal(MolarMass.FromKilogramsPerMole(2), 2.KilogramsPerMole());
public void GetHashCode_Equals() { var quantity = MolarMass.FromKilogramsPerMole(1.0); Assert.Equal(new { MolarMass.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }