public void CompareToThrowsOnNull()
        {
            PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            pascalpersecond.CompareTo(null);
        }
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = PressureChangeRate.FromPascalsPerSecond(1);

            Assert.True(v.Equals(PressureChangeRate.FromPascalsPerSecond(1), PascalsPerSecondTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(PressureChangeRate.Zero, PascalsPerSecondTolerance, ComparisonType.Relative));
        }
        public void CompareToThrowsOnTypeMismatch()
        {
            PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            pascalpersecond.CompareTo(new object());
        }
Esempio n. 4
0
        public void EqualsIsImplemented()
        {
            PressureChangeRate v = PressureChangeRate.FromPascalsPerSecond(1);

            Assert.True(v.Equals(PressureChangeRate.FromPascalsPerSecond(1)));
            Assert.False(v.Equals(PressureChangeRate.Zero));
        }
Esempio n. 5
0
        public void FromPascalsPerSecond_WithInfinityValue_CreateQuantityAndAffectInfinityValue()
        {
            var positiveInfinityQuantity = PressureChangeRate.FromPascalsPerSecond(double.PositiveInfinity);
            var negativeInfinityQuantity = PressureChangeRate.FromPascalsPerSecond(double.NegativeInfinity);

            Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value));
            Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value));
        }
        public void Equals_SameType_IsImplemented()
        {
            var a = PressureChangeRate.FromPascalsPerSecond(1);
            var b = PressureChangeRate.FromPascalsPerSecond(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
        public void CompareToIsImplemented()
        {
            PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);

            Assert.AreEqual(0, pascalpersecond.CompareTo(pascalpersecond));
            Assert.Greater(pascalpersecond.CompareTo(PressureChangeRate.Zero), 0);
            Assert.Less(PressureChangeRate.Zero.CompareTo(pascalpersecond), 0);
        }
        public void CompareToIsImplemented()
        {
            PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);

            Assert.Equal(0, pascalpersecond.CompareTo(pascalpersecond));
            Assert.True(pascalpersecond.CompareTo(PressureChangeRate.Zero) > 0);
            Assert.True(PressureChangeRate.Zero.CompareTo(pascalpersecond) < 0);
        }
Esempio n. 9
0
        public void PascalPerSecondToPressureChangeRateUnits()
        {
            PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);

            AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, pascalpersecond.AtmospheresPerSecond, AtmospheresPerSecondTolerance);
            AssertEx.EqualTolerance(KilopascalsPerSecondInOnePascalPerSecond, pascalpersecond.KilopascalsPerSecond, KilopascalsPerSecondTolerance);
            AssertEx.EqualTolerance(MegapascalsPerSecondInOnePascalPerSecond, pascalpersecond.MegapascalsPerSecond, MegapascalsPerSecondTolerance);
            AssertEx.EqualTolerance(PascalsPerSecondInOnePascalPerSecond, pascalpersecond.PascalsPerSecond, PascalsPerSecondTolerance);
        }
Esempio n. 10
0
        public void As()
        {
            var pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);

            AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.AtmospherePerSecond), AtmospheresPerSecondTolerance);
            AssertEx.EqualTolerance(KilopascalsPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.KilopascalPerSecond), KilopascalsPerSecondTolerance);
            AssertEx.EqualTolerance(MegapascalsPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.MegapascalPerSecond), MegapascalsPerSecondTolerance);
            AssertEx.EqualTolerance(PascalsPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.PascalPerSecond), PascalsPerSecondTolerance);
        }
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = PressureChangeRate.FromPascalsPerSecond(1);
            object b = PressureChangeRate.FromPascalsPerSecond(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
Esempio n. 12
0
        public void ConversionRoundTrip()
        {
            PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);

            AssertEx.EqualTolerance(1, PressureChangeRate.FromAtmospheresPerSecond(pascalpersecond.AtmospheresPerSecond).PascalsPerSecond, AtmospheresPerSecondTolerance);
            AssertEx.EqualTolerance(1, PressureChangeRate.FromKilopascalsPerSecond(pascalpersecond.KilopascalsPerSecond).PascalsPerSecond, KilopascalsPerSecondTolerance);
            AssertEx.EqualTolerance(1, PressureChangeRate.FromMegapascalsPerSecond(pascalpersecond.MegapascalsPerSecond).PascalsPerSecond, MegapascalsPerSecondTolerance);
            AssertEx.EqualTolerance(1, PressureChangeRate.FromPascalsPerSecond(pascalpersecond.PascalsPerSecond).PascalsPerSecond, PascalsPerSecondTolerance);
        }
        public void ArithmeticOperators()
        {
            PressureChangeRate v = PressureChangeRate.FromPascalsPerSecond(1);

            AssertEx.EqualTolerance(-1, -v.PascalsPerSecond, PascalsPerSecondTolerance);
            AssertEx.EqualTolerance(2, (PressureChangeRate.FromPascalsPerSecond(3) - v).PascalsPerSecond, PascalsPerSecondTolerance);
            AssertEx.EqualTolerance(2, (v + v).PascalsPerSecond, PascalsPerSecondTolerance);
            AssertEx.EqualTolerance(10, (v * 10).PascalsPerSecond, PascalsPerSecondTolerance);
            AssertEx.EqualTolerance(10, (10 * v).PascalsPerSecond, PascalsPerSecondTolerance);
            AssertEx.EqualTolerance(2, (PressureChangeRate.FromPascalsPerSecond(10) / 5).PascalsPerSecond, PascalsPerSecondTolerance);
            AssertEx.EqualTolerance(2, PressureChangeRate.FromPascalsPerSecond(10) / PressureChangeRate.FromPascalsPerSecond(5), PascalsPerSecondTolerance);
        }
Esempio n. 14
0
        public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
        {
            var pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);

            Assert.Throws <ArgumentException>(() => pascalpersecond.ToUnit(UnitSystem.SI));
            Assert.Throws <ArgumentException>(() => pascalpersecond.ToUnit(UnitSystem.CGS));
            Assert.Throws <ArgumentException>(() => pascalpersecond.ToUnit(UnitSystem.BI));
            Assert.Throws <ArgumentException>(() => pascalpersecond.ToUnit(UnitSystem.EE));
            Assert.Throws <ArgumentException>(() => pascalpersecond.ToUnit(UnitSystem.USC));
            Assert.Throws <ArgumentException>(() => pascalpersecond.ToUnit(UnitSystem.FPS));
            Assert.Throws <ArgumentException>(() => pascalpersecond.ToUnit(UnitSystem.Astronomical));
        }
Esempio n. 15
0
        public void EqualityOperators()
        {
            PressureChangeRate a = PressureChangeRate.FromPascalsPerSecond(1);
            PressureChangeRate b = PressureChangeRate.FromPascalsPerSecond(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()
        {
            PressureChangeRate onePascalPerSecond  = PressureChangeRate.FromPascalsPerSecond(1);
            PressureChangeRate twoPascalsPerSecond = PressureChangeRate.FromPascalsPerSecond(2);

            Assert.True(onePascalPerSecond < twoPascalsPerSecond);
            Assert.True(onePascalPerSecond <= twoPascalsPerSecond);
            Assert.True(twoPascalsPerSecond > onePascalPerSecond);
            Assert.True(twoPascalsPerSecond >= onePascalPerSecond);

            Assert.False(onePascalPerSecond > twoPascalsPerSecond);
            Assert.False(onePascalPerSecond >= twoPascalsPerSecond);
            Assert.False(twoPascalsPerSecond < onePascalPerSecond);
            Assert.False(twoPascalsPerSecond <= onePascalPerSecond);
        }
Esempio n. 17
0
        public void PascalPerSecondToPressureChangeRateUnits()
        {
            PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);

            AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, pascalpersecond.AtmospheresPerSecond, AtmospheresPerSecondTolerance);
            AssertEx.EqualTolerance(KilopascalsPerMinuteInOnePascalPerSecond, pascalpersecond.KilopascalsPerMinute, KilopascalsPerMinuteTolerance);
            AssertEx.EqualTolerance(KilopascalsPerSecondInOnePascalPerSecond, pascalpersecond.KilopascalsPerSecond, KilopascalsPerSecondTolerance);
            AssertEx.EqualTolerance(KilopoundsForcePerSquareInchPerMinuteInOnePascalPerSecond, pascalpersecond.KilopoundsForcePerSquareInchPerMinute, KilopoundsForcePerSquareInchPerMinuteTolerance);
            AssertEx.EqualTolerance(KilopoundsForcePerSquareInchPerSecondInOnePascalPerSecond, pascalpersecond.KilopoundsForcePerSquareInchPerSecond, KilopoundsForcePerSquareInchPerSecondTolerance);
            AssertEx.EqualTolerance(MegapascalsPerMinuteInOnePascalPerSecond, pascalpersecond.MegapascalsPerMinute, MegapascalsPerMinuteTolerance);
            AssertEx.EqualTolerance(MegapascalsPerSecondInOnePascalPerSecond, pascalpersecond.MegapascalsPerSecond, MegapascalsPerSecondTolerance);
            AssertEx.EqualTolerance(MegapoundsForcePerSquareInchPerMinuteInOnePascalPerSecond, pascalpersecond.MegapoundsForcePerSquareInchPerMinute, MegapoundsForcePerSquareInchPerMinuteTolerance);
            AssertEx.EqualTolerance(MegapoundsForcePerSquareInchPerSecondInOnePascalPerSecond, pascalpersecond.MegapoundsForcePerSquareInchPerSecond, MegapoundsForcePerSquareInchPerSecondTolerance);
            AssertEx.EqualTolerance(PascalsPerMinuteInOnePascalPerSecond, pascalpersecond.PascalsPerMinute, PascalsPerMinuteTolerance);
            AssertEx.EqualTolerance(PascalsPerSecondInOnePascalPerSecond, pascalpersecond.PascalsPerSecond, PascalsPerSecondTolerance);
            AssertEx.EqualTolerance(PoundsForcePerSquareInchPerMinuteInOnePascalPerSecond, pascalpersecond.PoundsForcePerSquareInchPerMinute, PoundsForcePerSquareInchPerMinuteTolerance);
            AssertEx.EqualTolerance(PoundsForcePerSquareInchPerSecondInOnePascalPerSecond, pascalpersecond.PoundsForcePerSquareInchPerSecond, PoundsForcePerSquareInchPerSecondTolerance);
        }
        public void EqualityOperators()
        {
            var a = PressureChangeRate.FromPascalsPerSecond(1);
            var b = PressureChangeRate.FromPascalsPerSecond(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 ToUnit()
        {
            var pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1);

            var atmospherepersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.AtmospherePerSecond);

            AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, (double)atmospherepersecondQuantity.Value, AtmospheresPerSecondTolerance);
            Assert.Equal(PressureChangeRateUnit.AtmospherePerSecond, atmospherepersecondQuantity.Unit);

            var kilopascalperminuteQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.KilopascalPerMinute);

            AssertEx.EqualTolerance(KilopascalsPerMinuteInOnePascalPerSecond, (double)kilopascalperminuteQuantity.Value, KilopascalsPerMinuteTolerance);
            Assert.Equal(PressureChangeRateUnit.KilopascalPerMinute, kilopascalperminuteQuantity.Unit);

            var kilopascalpersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.KilopascalPerSecond);

            AssertEx.EqualTolerance(KilopascalsPerSecondInOnePascalPerSecond, (double)kilopascalpersecondQuantity.Value, KilopascalsPerSecondTolerance);
            Assert.Equal(PressureChangeRateUnit.KilopascalPerSecond, kilopascalpersecondQuantity.Unit);

            var megapascalperminuteQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.MegapascalPerMinute);

            AssertEx.EqualTolerance(MegapascalsPerMinuteInOnePascalPerSecond, (double)megapascalperminuteQuantity.Value, MegapascalsPerMinuteTolerance);
            Assert.Equal(PressureChangeRateUnit.MegapascalPerMinute, megapascalperminuteQuantity.Unit);

            var megapascalpersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.MegapascalPerSecond);

            AssertEx.EqualTolerance(MegapascalsPerSecondInOnePascalPerSecond, (double)megapascalpersecondQuantity.Value, MegapascalsPerSecondTolerance);
            Assert.Equal(PressureChangeRateUnit.MegapascalPerSecond, megapascalpersecondQuantity.Unit);

            var pascalperminuteQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.PascalPerMinute);

            AssertEx.EqualTolerance(PascalsPerMinuteInOnePascalPerSecond, (double)pascalperminuteQuantity.Value, PascalsPerMinuteTolerance);
            Assert.Equal(PressureChangeRateUnit.PascalPerMinute, pascalperminuteQuantity.Unit);

            var pascalpersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.PascalPerSecond);

            AssertEx.EqualTolerance(PascalsPerSecondInOnePascalPerSecond, (double)pascalpersecondQuantity.Value, PascalsPerSecondTolerance);
            Assert.Equal(PressureChangeRateUnit.PascalPerSecond, pascalpersecondQuantity.Unit);
        }
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = PressureChangeRate.FromPascalsPerSecond(value);

            Assert.Equal(PressureChangeRate.FromPascalsPerSecond(-value), -quantity);
        }
        public void GetHashCode_Equals()
        {
            var quantity = PressureChangeRate.FromPascalsPerSecond(1.0);

            Assert.Equal(new { PressureChangeRate.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = PressureChangeRate.FromPascalsPerSecond(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = PressureChangeRate.FromPascalsPerSecond(1.0);

            Assert.Equal(PressureChangeRate.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
        public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo()
        {
            var quantity = PressureChangeRate.FromPascalsPerSecond(1.0);

            Assert.Equal(PressureChangeRate.Info, Convert.ChangeType(quantity, typeof(QuantityInfo)));
        }
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = PressureChangeRate.FromPascalsPerSecond(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PressureChangeRateUnit)));
        }
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = PressureChangeRate.FromPascalsPerSecond(1.0);

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

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

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = PressureChangeRate.FromPascalsPerSecond(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
        public void Convert_ToInt16_EqualsValueAsSameType()
        {
            var quantity = PressureChangeRate.FromPascalsPerSecond(1.0);

            Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity));
        }