public void CompareToThrowsOnNull() { VitaminA internationalunit = VitaminA.FromInternationalUnits(1); // ReSharper disable once ReturnValueOfPureMethodIsNotUsed internationalunit.CompareTo(null); }
public void EqualsIsImplemented() { VitaminA v = VitaminA.FromInternationalUnits(1); Assert.IsTrue(v.Equals(VitaminA.FromInternationalUnits(1))); Assert.IsFalse(v.Equals(VitaminA.Zero)); }
public void EqualsIsImplemented() { VitaminA v = VitaminA.FromInternationalUnits(1); Assert.True(v.Equals(VitaminA.FromInternationalUnits(1), VitaminA.FromInternationalUnits(InternationalUnitsTolerance))); Assert.False(v.Equals(VitaminA.Zero, VitaminA.FromInternationalUnits(InternationalUnitsTolerance))); }
public void Equals_RelativeTolerance_IsImplemented() { var v = VitaminA.FromInternationalUnits(1); Assert.True(v.Equals(VitaminA.FromInternationalUnits(1), InternationalUnitsTolerance, ComparisonType.Relative)); Assert.False(v.Equals(VitaminA.Zero, InternationalUnitsTolerance, ComparisonType.Relative)); }
public void CompareToThrowsOnTypeMismatch() { VitaminA internationalunit = VitaminA.FromInternationalUnits(1); // ReSharper disable once ReturnValueOfPureMethodIsNotUsed internationalunit.CompareTo(new object()); }
public void Equals_SameType_IsImplemented() { var a = VitaminA.FromInternationalUnits(1); var b = VitaminA.FromInternationalUnits(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); }
public void CompareToIsImplemented() { VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.Equal(0, internationalunit.CompareTo(internationalunit)); Assert.True(internationalunit.CompareTo(VitaminA.Zero) > 0); Assert.True(VitaminA.Zero.CompareTo(internationalunit) < 0); }
public void FromInternationalUnits_WithInfinityValue_CreateQuantityAndAffectInfinityValue() { var positiveInfinityQuantity = VitaminA.FromInternationalUnits(double.PositiveInfinity); var negativeInfinityQuantity = VitaminA.FromInternationalUnits(double.NegativeInfinity); Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value)); Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value)); }
public void CompareToIsImplemented() { VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.AreEqual(0, internationalunit.CompareTo(internationalunit)); Assert.Greater(internationalunit.CompareTo(VitaminA.Zero), 0); Assert.Less(VitaminA.Zero.CompareTo(internationalunit), 0); }
public void ToUnit() { var internationalunit = VitaminA.FromInternationalUnits(1); var internationalunitQuantity = internationalunit.ToUnit(VitaminAUnit.InternationalUnit); AssertEx.EqualTolerance(InternationalUnitsInOneInternationalUnit, (double)internationalunitQuantity.Value, InternationalUnitsTolerance); Assert.Equal(VitaminAUnit.InternationalUnit, internationalunitQuantity.Unit); }
public void Equals_QuantityAsObject_IsImplemented() { object a = VitaminA.FromInternationalUnits(1); object b = VitaminA.FromInternationalUnits(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)null)); }
public void ArithmeticOperators() { VitaminA v = VitaminA.FromInternationalUnits(1); Assert.AreEqual(-1, -v.InternationalUnits, InternationalUnitsTolerance); Assert.AreEqual(2, (VitaminA.FromInternationalUnits(3) - v).InternationalUnits, InternationalUnitsTolerance); Assert.AreEqual(2, (v + v).InternationalUnits, InternationalUnitsTolerance); Assert.AreEqual(10, (v * 10).InternationalUnits, InternationalUnitsTolerance); Assert.AreEqual(10, (10 * v).InternationalUnits, InternationalUnitsTolerance); Assert.AreEqual(2, (VitaminA.FromInternationalUnits(10) / 5).InternationalUnits, InternationalUnitsTolerance); Assert.AreEqual(2, VitaminA.FromInternationalUnits(10) / VitaminA.FromInternationalUnits(5), InternationalUnitsTolerance); }
public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported() { var internationalunit = VitaminA.FromInternationalUnits(1); Assert.Throws <ArgumentException>(() => internationalunit.ToUnit(UnitSystem.SI)); Assert.Throws <ArgumentException>(() => internationalunit.ToUnit(UnitSystem.CGS)); Assert.Throws <ArgumentException>(() => internationalunit.ToUnit(UnitSystem.BI)); Assert.Throws <ArgumentException>(() => internationalunit.ToUnit(UnitSystem.EE)); Assert.Throws <ArgumentException>(() => internationalunit.ToUnit(UnitSystem.USC)); Assert.Throws <ArgumentException>(() => internationalunit.ToUnit(UnitSystem.FPS)); Assert.Throws <ArgumentException>(() => internationalunit.ToUnit(UnitSystem.Astronomical)); }
public void EqualityOperators() { VitaminA a = VitaminA.FromInternationalUnits(1); VitaminA b = VitaminA.FromInternationalUnits(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() { VitaminA oneInternationalUnit = VitaminA.FromInternationalUnits(1); VitaminA twoInternationalUnits = VitaminA.FromInternationalUnits(2); Assert.True(oneInternationalUnit < twoInternationalUnits); Assert.True(oneInternationalUnit <= twoInternationalUnits); Assert.True(twoInternationalUnits > oneInternationalUnit); Assert.True(twoInternationalUnits >= oneInternationalUnit); Assert.False(oneInternationalUnit > twoInternationalUnits); Assert.False(oneInternationalUnit >= twoInternationalUnits); Assert.False(twoInternationalUnits < oneInternationalUnit); Assert.False(twoInternationalUnits <= oneInternationalUnit); }
public void EqualityOperators() { var a = VitaminA.FromInternationalUnits(1); var b = VitaminA.FromInternationalUnits(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 ConversionRoundTrip() { VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.AreEqual(1, VitaminA.FromInternationalUnits(internationalunit.InternationalUnits).InternationalUnits, InternationalUnitsTolerance); }
public void As() { var internationalunit = VitaminA.FromInternationalUnits(1); Assert.AreEqual(InternationalUnitsInOneInternationalUnit, internationalunit.As(VitaminAUnit.InternationalUnit), InternationalUnitsTolerance); }
public void InternationalUnitToVitaminAUnits() { VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.AreEqual(InternationalUnitsInOneInternationalUnit, internationalunit.InternationalUnits, InternationalUnitsTolerance); }
public void EqualsReturnsFalseOnNull() { VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.IsFalse(internationalunit.Equals(null)); }
public void GetHashCode_Equals() { var quantity = VitaminA.FromInternationalUnits(1.0); Assert.Equal(new { VitaminA.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
/// <inheritdoc cref="VitaminA.FromInternationalUnits(UnitsNet.QuantityValue)" /> public static VitaminA InternationalUnits(this decimal value) => VitaminA.FromInternationalUnits(Convert.ToDouble(value));
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = VitaminA.FromInternationalUnits(1.0); Assert.Equal(VitaminA.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = VitaminA.FromInternationalUnits(value); Assert.Equal(VitaminA.FromInternationalUnits(-value), -quantity); }
/// <inheritdoc cref="VitaminA.FromInternationalUnits(UnitsNet.QuantityValue)" /> public static VitaminA InternationalUnits(this double value) => VitaminA.FromInternationalUnits(value);
public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { var quantity = VitaminA.FromInternationalUnits(1.0); Assert.Equal(VitaminA.Info, Convert.ChangeType(quantity, typeof(QuantityInfo))); }
/// <inheritdoc cref="VitaminA.FromInternationalUnits(UnitsNet.QuantityValue)" /> public static VitaminA?InternationalUnits(this float?value) => VitaminA.FromInternationalUnits(value);
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = VitaminA.FromInternationalUnits(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
/// <inheritdoc cref="VitaminA.FromInternationalUnits(UnitsNet.QuantityValue)" /> public static VitaminA?InternationalUnits(this decimal?value) => VitaminA.FromInternationalUnits(value == null ? (double?)null : Convert.ToDouble(value.Value));
public void EqualsReturnsFalseOnTypeMismatch() { VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.IsFalse(internationalunit.Equals(new object())); }