public void Equals_RelativeTolerance_IsImplemented() { var v = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.True(v.Equals(TemperatureCoefficient.FromPercentageByKelvins(1), PercentageByKelvinsTolerance, ComparisonType.Relative)); Assert.False(v.Equals(TemperatureCoefficient.Zero, PercentageByKelvinsTolerance, ComparisonType.Relative)); }
public void Equals_SameType_IsImplemented() { var a = TemperatureCoefficient.FromPercentageByKelvins(1); var b = TemperatureCoefficient.FromPercentageByKelvins(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); }
public void CompareToIsImplemented() { TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.Equal(0, percentagebykelvin.CompareTo(percentagebykelvin)); Assert.True(percentagebykelvin.CompareTo(TemperatureCoefficient.Zero) > 0); Assert.True(TemperatureCoefficient.Zero.CompareTo(percentagebykelvin) < 0); }
public void ToUnit() { var percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); var percentagebykelvinQuantity = percentagebykelvin.ToUnit(TemperatureCoefficientUnit.PercentageByKelvin); AssertEx.EqualTolerance(PercentageByKelvinsInOnePercentageByKelvin, (double)percentagebykelvinQuantity.Value, PercentageByKelvinsTolerance); Assert.Equal(TemperatureCoefficientUnit.PercentageByKelvin, percentagebykelvinQuantity.Unit); }
public void Equals_QuantityAsObject_IsImplemented() { object a = TemperatureCoefficient.FromPercentageByKelvins(1); object b = TemperatureCoefficient.FromPercentageByKelvins(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)null)); }
public void ArithmeticOperators() { TemperatureCoefficient v = TemperatureCoefficient.FromPercentageByKelvins(1); AssertEx.EqualTolerance(-1, -v.PercentageByKelvins, PercentageByKelvinsTolerance); AssertEx.EqualTolerance(2, (TemperatureCoefficient.FromPercentageByKelvins(3) - v).PercentageByKelvins, PercentageByKelvinsTolerance); AssertEx.EqualTolerance(2, (v + v).PercentageByKelvins, PercentageByKelvinsTolerance); AssertEx.EqualTolerance(10, (v * 10).PercentageByKelvins, PercentageByKelvinsTolerance); AssertEx.EqualTolerance(10, (10 * v).PercentageByKelvins, PercentageByKelvinsTolerance); AssertEx.EqualTolerance(2, (TemperatureCoefficient.FromPercentageByKelvins(10) / 5).PercentageByKelvins, PercentageByKelvinsTolerance); AssertEx.EqualTolerance(2, TemperatureCoefficient.FromPercentageByKelvins(10) / TemperatureCoefficient.FromPercentageByKelvins(5), PercentageByKelvinsTolerance); }
public void ComparisonOperators() { TemperatureCoefficient onePercentageByKelvin = TemperatureCoefficient.FromPercentageByKelvins(1); TemperatureCoefficient twoPercentageByKelvins = TemperatureCoefficient.FromPercentageByKelvins(2); Assert.True(onePercentageByKelvin < twoPercentageByKelvins); Assert.True(onePercentageByKelvin <= twoPercentageByKelvins); Assert.True(twoPercentageByKelvins > onePercentageByKelvin); Assert.True(twoPercentageByKelvins >= onePercentageByKelvin); Assert.False(onePercentageByKelvin > twoPercentageByKelvins); Assert.False(onePercentageByKelvin >= twoPercentageByKelvins); Assert.False(twoPercentageByKelvins < onePercentageByKelvin); Assert.False(twoPercentageByKelvins <= onePercentageByKelvin); }
public void EqualityOperators() { var a = TemperatureCoefficient.FromPercentageByKelvins(1); var b = TemperatureCoefficient.FromPercentageByKelvins(2); // 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 }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null)); }
public void EqualsReturnsFalseOnNull() { TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.False(percentagebykelvin.Equals(null)); }
public void FromPercentageByKelvins_WithNanValue_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => TemperatureCoefficient.FromPercentageByKelvins(double.NaN)); }
public void Convert_ToString_EqualsToString() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TemperatureCoefficientUnit))); }
public void As() { var percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); AssertEx.EqualTolerance(PercentageByKelvinsInOnePercentageByKelvin, percentagebykelvin.As(TemperatureCoefficientUnit.PercentageByKelvin), PercentageByKelvinsTolerance); }
public void CompareToThrowsOnNull() { TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.Throws <ArgumentNullException>(() => percentagebykelvin.CompareTo(null)); }
public void CompareToThrowsOnTypeMismatch() { TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.Throws <ArgumentException>(() => percentagebykelvin.CompareTo(new object())); }
public void ConversionRoundTrip() { TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); AssertEx.EqualTolerance(1, TemperatureCoefficient.FromPercentageByKelvins(percentagebykelvin.PercentageByKelvins).PercentageByKelvins, PercentageByKelvinsTolerance); }
public void Convert_ToDecimal_EqualsValueAsSameType() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(TemperatureCoefficient.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void GetHashCode_Equals() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(new { TemperatureCoefficient.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(QuantityType.TemperatureCoefficient, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(TemperatureCoefficient.FromPercentageByKelvins(1), -1, ComparisonType.Relative)); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void EqualsReturnsFalseOnTypeMismatch() { TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.False(percentagebykelvin.Equals(new object())); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = TemperatureCoefficient.FromPercentageByKelvins(value); Assert.Equal(TemperatureCoefficient.FromPercentageByKelvins(-value), -quantity); }
public void FromPercentageByKelvins_WithInfinityValue_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => TemperatureCoefficient.FromPercentageByKelvins(double.PositiveInfinity)); Assert.Throws <ArgumentException>(() => TemperatureCoefficient.FromPercentageByKelvins(double.NegativeInfinity)); }