public void EqualsReturnsFalseOnTypeMismatch()
        {
            WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1);

            Assert.False(metertothesixth.Equals(new object()));
        }
        public void EqualsReturnsFalseOnNull()
        {
            WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1);

            Assert.False(metertothesixth.Equals(null));
        }
        public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Equal(WarpingMomentOfInertia.Info, Convert.ChangeType(quantity, typeof(QuantityInfo)));
        }
예제 #4
0
        public void ToUnit_WithNullUnitSystem_ThrowsNullException()
        {
            var metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1);

            Assert.Throws <ArgumentNullException>(() => metertothesixth.ToUnit(null));
        }
        public void Convert_ToString_EqualsToString()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(WarpingMomentOfInertia)));
        }
 public void FromMetersToTheSixth_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.NaN));
 }
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
 public static WarpingMomentOfInertia MetersToTheSixth <T>(this T value) =>
 WarpingMomentOfInertia.FromMetersToTheSixth(Convert.ToDecimal(value));
 public void FromMetersToTheSixth_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.NegativeInfinity));
 }
예제 #11
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value);

            Assert.Equal(WarpingMomentOfInertia.FromMetersToTheSixth(-value), -quantity);
        }
예제 #12
0
        public void GetHashCode_Equals()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Equal(new { WarpingMomentOfInertia.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
예제 #13
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = WarpingMomentOfInertia.FromMetersToTheSixth(1).ToBaseUnit();

            Assert.Equal(WarpingMomentOfInertia.BaseUnit, quantityInBaseUnit.Unit);
        }
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
        public void ArithmeticOperators()
        {
            WarpingMomentOfInertia v = WarpingMomentOfInertia.FromMetersToTheSixth(1);

            AssertEx.EqualTolerance(-1, -v.MetersToTheSixth, MetersToTheSixthTolerance);
            AssertEx.EqualTolerance(2, (WarpingMomentOfInertia.FromMetersToTheSixth(3) - v).MetersToTheSixth, MetersToTheSixthTolerance);
            AssertEx.EqualTolerance(2, (v + v).MetersToTheSixth, MetersToTheSixthTolerance);
            AssertEx.EqualTolerance(10, (v * 10).MetersToTheSixth, MetersToTheSixthTolerance);
            AssertEx.EqualTolerance(10, (10 * v).MetersToTheSixth, MetersToTheSixthTolerance);
            AssertEx.EqualTolerance(2, (WarpingMomentOfInertia.FromMetersToTheSixth(10) / 5).MetersToTheSixth, MetersToTheSixthTolerance);
            AssertEx.EqualTolerance(2, WarpingMomentOfInertia.FromMetersToTheSixth(10) / WarpingMomentOfInertia.FromMetersToTheSixth(5), MetersToTheSixthTolerance);
        }
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
        public void CompareToThrowsOnTypeMismatch()
        {
            WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1);

            Assert.Throws <ArgumentException>(() => metertothesixth.CompareTo(new object()));
        }
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
        public void CompareToThrowsOnNull()
        {
            WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1);

            Assert.Throws <ArgumentNullException>(() => metertothesixth.CompareTo(null));
        }
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(WarpingMomentOfInertiaUnit)));
        }
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = WarpingMomentOfInertia.FromMetersToTheSixth(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(WarpingMomentOfInertia.FromMetersToTheSixth(1), -1, ComparisonType.Relative));
        }
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0);

            Assert.Equal(WarpingMomentOfInertia.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
예제 #25
0
 public void NumberToMetersToTheSixthTest() =>
 Assert.Equal(WarpingMomentOfInertia.FromMetersToTheSixth(2), 2.MetersToTheSixth());