public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Example #2
0
        public void EqualsReturnsFalseOnNull()
        {
            MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1);

            Assert.False(joulepermole.Equals(null));
        }
Example #3
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Example #4
0
        public void CompareToThrowsOnTypeMismatch()
        {
            MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1);

            Assert.Throws <ArgumentException>(() => joulepermole.CompareTo(new object()));
        }
Example #5
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = MolarEnergy.FromJoulesPerMole(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(MolarEnergy.FromJoulesPerMole(1), -1, ComparisonType.Relative));
        }
Example #6
0
 /// <inheritdoc cref="MolarEnergy.FromKilojoulesPerMole(double?)"/>
 public static MolarEnergy?KilojoulesPerMole(this double?value) => MolarEnergy.FromKilojoulesPerMole(value);
Example #7
0
 public void FromJoulesPerMole_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => MolarEnergy.FromJoulesPerMole(double.NaN));
 }
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Equal(MolarEnergy.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarEnergyUnit)));
        }
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Equal(QuantityType.MolarEnergy, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(MolarEnergy)));
        }
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
        public void Convert_ToString_EqualsToString()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Example #15
0
 /// <inheritdoc cref="MolarEnergy.FromJoulesPerMole(double?)"/>
 public static MolarEnergy?JoulesPerMole(this decimal?value) => MolarEnergy.FromJoulesPerMole(value == null ? (double?)null : Convert.ToDouble(value.Value));
        public void GetHashCode_Equals()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Equal(new { MolarEnergy.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Example #17
0
 /// <inheritdoc cref="MolarEnergy.FromKilojoulesPerMole(double)"/>
 public static MolarEnergy KilojoulesPerMole(this long value) => MolarEnergy.FromKilojoulesPerMole(value);
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(decimal value)
        {
            var quantity = MolarEnergy.FromJoulesPerMole(value);

            Assert.Equal(MolarEnergy.FromJoulesPerMole(-value), -quantity);
        }
Example #19
0
 public void FromJoulesPerMole_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => MolarEnergy.FromJoulesPerMole(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => MolarEnergy.FromJoulesPerMole(double.NegativeInfinity));
 }
Example #20
0
 /// <inheritdoc cref="MolarEnergy.FromMegajoulesPerMole(double?)"/>
 public static MolarEnergy?MegajoulesPerMole(this double?value) => MolarEnergy.FromMegajoulesPerMole(value);
Example #21
0
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = MolarEnergy.FromJoulesPerMole(1).ToBaseUnit();

            Assert.Equal(MolarEnergy.BaseUnit, quantityInBaseUnit.Unit);
        }
Example #22
0
 /// <inheritdoc cref="MolarEnergy.FromMegajoulesPerMole(double)"/>
 public static MolarEnergy MegajoulesPerMole(this float value) => MolarEnergy.FromMegajoulesPerMole(value);
Example #23
0
        public void CompareToThrowsOnNull()
        {
            MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1);

            Assert.Throws <ArgumentNullException>(() => joulepermole.CompareTo(null));
        }
Example #24
0
 /// <inheritdoc cref="MolarEnergy.FromJoulesPerMole(double)"/>
 public static MolarEnergy JoulesPerMole(this double value) => MolarEnergy.FromJoulesPerMole(value);
Example #25
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1);

            Assert.False(joulepermole.Equals(new object()));
        }
Example #26
0
 /// <inheritdoc cref="MolarEnergy.FromJoulesPerMole(double?)"/>
 public static MolarEnergy?JoulesPerMole(this float?value) => MolarEnergy.FromJoulesPerMole(value);
Example #27
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
Example #28
0
 /// <inheritdoc cref="MolarEnergy.FromJoulesPerMole(double)"/>
 public static MolarEnergy JoulesPerMole(this decimal value) => MolarEnergy.FromJoulesPerMole(Convert.ToDouble(value));
Example #29
0
        public void Convert_ToBool_ThrowsInvalidCastException()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToBoolean(quantity));
        }
        public void Convert_ToInt32_EqualsValueAsSameType()
        {
            var quantity = MolarEnergy.FromJoulesPerMole(1.0);

            Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity));
        }