示例#1
0
        public void FromDecibelVolts_WithInfinityValue_CreateQuantityAndAffectInfinityValue()
        {
            var positiveInfinityQuantity = AmplitudeRatio.FromDecibelVolts(double.PositiveInfinity);
            var negativeInfinityQuantity = AmplitudeRatio.FromDecibelVolts(double.NegativeInfinity);

            Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value));
            Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value));
        }
示例#2
0
        public void CompareToIsImplemented()
        {
            AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            Assert.AreEqual(0, decibelvolt.CompareTo(decibelvolt));
            Assert.Greater(decibelvolt.CompareTo(AmplitudeRatio.Zero), 0);
            Assert.Less(AmplitudeRatio.Zero.CompareTo(decibelvolt), 0);
        }
        public void Equals_SameType_IsImplemented()
        {
            var a = AmplitudeRatio.FromDecibelVolts(1);
            var b = AmplitudeRatio.FromDecibelVolts(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
        public void ConversionRoundTrip()
        {
            AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            Assert.AreEqual(1, AmplitudeRatio.FromDecibelMicrovolts(decibelvolt.DecibelMicrovolts).DecibelVolts, DecibelMicrovoltsTolerance);
            Assert.AreEqual(1, AmplitudeRatio.FromDecibelMillivolts(decibelvolt.DecibelMillivolts).DecibelVolts, DecibelMillivoltsTolerance);
            Assert.AreEqual(1, AmplitudeRatio.FromDecibelVolts(decibelvolt.DecibelVolts).DecibelVolts, DecibelVoltsTolerance);
        }
        public void As()
        {
            var decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            Assert.AreEqual(DecibelMicrovoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelMicrovolt), DecibelMicrovoltsTolerance);
            Assert.AreEqual(DecibelMillivoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelMillivolt), DecibelMillivoltsTolerance);
            Assert.AreEqual(DecibelVoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelVolt), DecibelVoltsTolerance);
        }
        public void DecibelVoltToAmplitudeRatioUnits()
        {
            AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            Assert.AreEqual(DecibelMicrovoltsInOneDecibelVolt, decibelvolt.DecibelMicrovolts, DecibelMicrovoltsTolerance);
            Assert.AreEqual(DecibelMillivoltsInOneDecibelVolt, decibelvolt.DecibelMillivolts, DecibelMillivoltsTolerance);
            Assert.AreEqual(DecibelVoltsInOneDecibelVolt, decibelvolt.DecibelVolts, DecibelVoltsTolerance);
        }
示例#7
0
        public void CompareToIsImplemented()
        {
            AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            Assert.Equal(0, decibelvolt.CompareTo(decibelvolt));
            Assert.True(decibelvolt.CompareTo(AmplitudeRatio.Zero) > 0);
            Assert.True(AmplitudeRatio.Zero.CompareTo(decibelvolt) < 0);
        }
示例#8
0
        public void ExpectAmplitudeRatioConvertedToVoltageCorrectly(double amplitudeRatio, double expected)
        {
            // Voltage increases by powers of 10 for every 20 dBV increase in amplitude ratio.
            AmplitudeRatio ar = AmplitudeRatio.FromDecibelVolts(amplitudeRatio);

            double actual = ar.ToElectricPotential().Volts;

            Assert.Equal(expected, actual);
        }
示例#9
0
        public void ConversionRoundTrip()
        {
            AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelMicrovolts(decibelvolt.DecibelMicrovolts).DecibelVolts, DecibelMicrovoltsTolerance);
            AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelMillivolts(decibelvolt.DecibelMillivolts).DecibelVolts, DecibelMillivoltsTolerance);
            AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelsUnloaded(decibelvolt.DecibelsUnloaded).DecibelVolts, DecibelsUnloadedTolerance);
            AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelVolts(decibelvolt.DecibelVolts).DecibelVolts, DecibelVoltsTolerance);
        }
示例#10
0
        public void As()
        {
            var decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelMicrovolt), DecibelMicrovoltsTolerance);
            AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelMillivolt), DecibelMillivoltsTolerance);
            AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelUnloaded), DecibelsUnloadedTolerance);
            AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelVolt), DecibelVoltsTolerance);
        }
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = AmplitudeRatio.FromDecibelVolts(1);
            object b = AmplitudeRatio.FromDecibelVolts(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
示例#12
0
        public void DecibelVoltToAmplitudeRatioUnits()
        {
            AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, decibelvolt.DecibelMicrovolts, DecibelMicrovoltsTolerance);
            AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, decibelvolt.DecibelMillivolts, DecibelMillivoltsTolerance);
            AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, decibelvolt.DecibelsUnloaded, DecibelsUnloadedTolerance);
            AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, decibelvolt.DecibelVolts, DecibelVoltsTolerance);
        }
示例#13
0
        public void LogarithmicArithmeticOperators()
        {
            AmplitudeRatio v = AmplitudeRatio.FromDecibelVolts(40);

            Assert.AreEqual(-40, -v.DecibelVolts, DecibelVoltsTolerance);
            AssertLogarithmicAddition();
            AssertLogarithmicSubtraction();
            Assert.AreEqual(50, (v * 10).DecibelVolts, DecibelVoltsTolerance);
            Assert.AreEqual(50, (10 * v).DecibelVolts, DecibelVoltsTolerance);
            Assert.AreEqual(35, (v / 5).DecibelVolts, DecibelVoltsTolerance);
            Assert.AreEqual(35, v / AmplitudeRatio.FromDecibelVolts(5), DecibelVoltsTolerance);
        }
示例#14
0
        public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
        {
            var decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            Assert.Throws <ArgumentException>(() => decibelvolt.ToUnit(UnitSystem.SI));
            Assert.Throws <ArgumentException>(() => decibelvolt.ToUnit(UnitSystem.CGS));
            Assert.Throws <ArgumentException>(() => decibelvolt.ToUnit(UnitSystem.BI));
            Assert.Throws <ArgumentException>(() => decibelvolt.ToUnit(UnitSystem.EE));
            Assert.Throws <ArgumentException>(() => decibelvolt.ToUnit(UnitSystem.USC));
            Assert.Throws <ArgumentException>(() => decibelvolt.ToUnit(UnitSystem.FPS));
            Assert.Throws <ArgumentException>(() => decibelvolt.ToUnit(UnitSystem.Astronomical));
        }
示例#15
0
        public void EqualityOperators()
        {
            AmplitudeRatio a = AmplitudeRatio.FromDecibelVolts(1);
            AmplitudeRatio b = AmplitudeRatio.FromDecibelVolts(2);

// ReSharper disable EqualExpressionComparison
            Assert.True(a == a);
            Assert.True(a != b);

            Assert.False(a == b);
            Assert.False(a != a);
// ReSharper restore EqualExpressionComparison
        }
示例#16
0
        public void ComparisonOperators()
        {
            AmplitudeRatio oneDecibelVolt  = AmplitudeRatio.FromDecibelVolts(1);
            AmplitudeRatio twoDecibelVolts = AmplitudeRatio.FromDecibelVolts(2);

            Assert.True(oneDecibelVolt < twoDecibelVolts);
            Assert.True(oneDecibelVolt <= twoDecibelVolts);
            Assert.True(twoDecibelVolts > oneDecibelVolt);
            Assert.True(twoDecibelVolts >= oneDecibelVolt);

            Assert.False(oneDecibelVolt > twoDecibelVolts);
            Assert.False(oneDecibelVolt >= twoDecibelVolts);
            Assert.False(twoDecibelVolts < oneDecibelVolt);
            Assert.False(twoDecibelVolts <= oneDecibelVolt);
        }
示例#17
0
        public void EqualityOperators()
        {
            var a = AmplitudeRatio.FromDecibelVolts(1);
            var b = AmplitudeRatio.FromDecibelVolts(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 decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            var decibelmicrovoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelMicrovolt);

            AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, (double)decibelmicrovoltQuantity.Value, DecibelMicrovoltsTolerance);
            Assert.Equal(AmplitudeRatioUnit.DecibelMicrovolt, decibelmicrovoltQuantity.Unit);

            var decibelmillivoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelMillivolt);

            AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, (double)decibelmillivoltQuantity.Value, DecibelMillivoltsTolerance);
            Assert.Equal(AmplitudeRatioUnit.DecibelMillivolt, decibelmillivoltQuantity.Unit);

            var decibelunloadedQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelUnloaded);

            AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, (double)decibelunloadedQuantity.Value, DecibelsUnloadedTolerance);
            Assert.Equal(AmplitudeRatioUnit.DecibelUnloaded, decibelunloadedQuantity.Unit);

            var decibelvoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelVolt);

            AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, (double)decibelvoltQuantity.Value, DecibelVoltsTolerance);
            Assert.Equal(AmplitudeRatioUnit.DecibelVolt, decibelvoltQuantity.Unit);
        }
示例#19
0
        public void EqualsReturnsFalseOnNull()
        {
            AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            Assert.IsFalse(decibelvolt.Equals(null));
        }
示例#20
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            Assert.IsFalse(decibelvolt.Equals(new object()));
        }
        public void GetHashCode_Equals()
        {
            var quantity = AmplitudeRatio.FromDecibelVolts(1.0);

            Assert.Equal(new { AmplitudeRatio.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = AmplitudeRatio.FromDecibelVolts(value);

            Assert.Equal(AmplitudeRatio.FromDecibelVolts(-value), -quantity);
        }
 /// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(double)"/>
 public static AmplitudeRatio DecibelVolts(this double value) => AmplitudeRatio.FromDecibelVolts(value);
示例#24
0
        protected override void AssertLogarithmicSubtraction()
        {
            AmplitudeRatio v = AmplitudeRatio.FromDecibelVolts(40);

            Assert.AreEqual(46.6982292275, (AmplitudeRatio.FromDecibelVolts(50) - v).DecibelVolts, DecibelVoltsTolerance);
        }
示例#25
0
        protected override void AssertLogarithmicAddition()
        {
            AmplitudeRatio v = AmplitudeRatio.FromDecibelVolts(40);

            Assert.AreEqual(46.0205999133, (v + v).DecibelVolts, DecibelVoltsTolerance);
        }
 /// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(double)"/>
 public static AmplitudeRatio DecibelVolts(this decimal value) => AmplitudeRatio.FromDecibelVolts(Convert.ToDouble(value));
 /// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(double?)"/>
 public static AmplitudeRatio?DecibelVolts(this float?value) => AmplitudeRatio.FromDecibelVolts(value);
示例#28
0
        public void CompareToThrowsOnTypeMismatch()
        {
            AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            Assert.Throws <ArgumentException>(() => decibelvolt.CompareTo(new object()));
        }
 /// <inheritdoc cref="AmplitudeRatio.FromDecibelVolts(double?)"/>
 public static AmplitudeRatio?DecibelVolts(this decimal?value) => AmplitudeRatio.FromDecibelVolts(value == null ? (double?)null : Convert.ToDouble(value.Value));
示例#30
0
        public void CompareToThrowsOnNull()
        {
            AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1);

            Assert.Throws <ArgumentNullException>(() => decibelvolt.CompareTo(null));
        }