예제 #1
0
 public void NumberToDecibelWattsTest() =>
 Assert.Equal(PowerRatio.FromDecibelWatts(2), 2.DecibelWatts());
예제 #2
0
 /// <summary>
 ///     Gets a <see cref="AmplitudeRatio" /> from a <see cref="PowerRatio" />.
 /// </summary>
 /// <param name="powerRatio">The power ratio.</param>
 /// <param name="impedance">The input impedance of the load. This is usually 50, 75 or 600 ohms.</param>
 public static AmplitudeRatio ToAmplitudeRatio(this PowerRatio powerRatio, ElectricResistance impedance)
 {
     return(PowerRatio.ToAmplitudeRatio(powerRatio, impedance));
 }
        public void CompareToThrowsOnNull()
        {
            PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1);

            Assert.Throws <ArgumentNullException>(() => decibelwatt.CompareTo(null));
        }
예제 #4
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
예제 #5
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = PowerRatio.FromDecibelWatts(value);

            Assert.Equal(PowerRatio.FromDecibelWatts(-value), -quantity);
        }
예제 #6
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(PowerRatio)));
        }
예제 #7
0
        public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Equal(PowerRatio.Info, Convert.ChangeType(quantity, typeof(QuantityInfo)));
        }
예제 #8
0
        public void ToUnit_WithNullUnitSystem_ThrowsNullException()
        {
            var decibelwatt = PowerRatio.FromDecibelWatts(1);

            Assert.Throws <ArgumentNullException>(() => decibelwatt.ToUnit(null));
        }
예제 #9
0
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = PowerRatio.FromDecibelWatts(1).ToBaseUnit();

            Assert.Equal(PowerRatio.BaseUnit, quantityInBaseUnit.Unit);
        }
예제 #10
0
 public void FromDecibelWatts_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => PowerRatio.FromDecibelWatts(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => PowerRatio.FromDecibelWatts(double.NegativeInfinity));
 }
예제 #11
0
 public void FromDecibelWatts_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => PowerRatio.FromDecibelWatts(double.NaN));
 }
예제 #12
0
 /// <summary>
 ///     Gets a <see cref="PowerRatio" /> from a <see cref="Power" /> relative to one watt.
 /// </summary>
 /// <remarks>
 ///     Provides a nicer syntax for converting a power to a power ratio (relative to 1 watt).
 ///     <example>
 ///         <c>var powerRatio = power.ToPowerRatio();</c>
 ///     </example>
 /// </remarks>
 public static PowerRatio ToPowerRatio(this Power power)
 {
     return(PowerRatio.FromPower(power));
 }
예제 #13
0
 public void FromValueAndUnit()
 {
     AssertEx.EqualTolerance(1, PowerRatio.From(1, PowerRatioUnit.DecibelMilliwatt).DecibelMilliwatts, DecibelMilliwattsTolerance);
     AssertEx.EqualTolerance(1, PowerRatio.From(1, PowerRatioUnit.DecibelWatt).DecibelWatts, DecibelWattsTolerance);
 }
예제 #14
0
 /// <inheritdoc cref="PowerRatio.FromDecibelWatts(UnitsNet.QuantityValue)" />
 public static PowerRatio DecibelWatts <T>(this T value) =>
 PowerRatio.FromDecibelWatts(Convert.ToDouble(value));
예제 #15
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
예제 #16
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = PowerRatio.FromDecibelWatts(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(PowerRatio.FromDecibelWatts(1), -1, ComparisonType.Relative));
        }
예제 #17
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
예제 #18
0
        public void EqualsReturnsFalseOnNull()
        {
            PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1);

            Assert.False(decibelwatt.Equals(null));
        }
예제 #19
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PowerRatioUnit)));
        }
예제 #20
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
예제 #21
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Equal(PowerRatio.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
예제 #22
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
예제 #23
0
        public void GetHashCode_Equals()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Equal(new { PowerRatio.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
예제 #24
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
예제 #25
0
 /// <summary>
 ///     Gets a <see cref="Power" /> from a <see cref="PowerRatio" />.
 /// </summary>
 /// <remarks>
 ///     Provides a nicer syntax for converting a power ratio back to a power.
 ///     <example>
 ///         <c>var power = powerRatio.ToPower();</c>
 ///     </example>
 /// </remarks>
 public static Power ToPower(this PowerRatio powerRatio)
 {
     return(PowerRatio.ToPower(powerRatio));
 }
예제 #26
0
        public void Convert_ToInt32_EqualsValueAsSameType()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity));
        }
예제 #27
0
        public void CompareToThrowsOnTypeMismatch()
        {
            PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1);

            Assert.Throws <ArgumentException>(() => decibelwatt.CompareTo(new object()));
        }
예제 #28
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = PowerRatio.FromDecibelWatts(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
예제 #29
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1);

            Assert.False(decibelwatt.Equals(new object()));
        }
 /// <inheritdoc cref="PowerRatio.FromDecibelWatts(UnitsNet.QuantityValue)" />
 public static PowerRatio?DecibelWatts(this double?value) => PowerRatio.FromDecibelWatts(value);