public void NumberToDecibelWattsTest() => Assert.Equal(PowerRatio.FromDecibelWatts(2), 2.DecibelWatts());
/// <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)); }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = PowerRatio.FromDecibelWatts(value); Assert.Equal(PowerRatio.FromDecibelWatts(-value), -quantity); }
public void Convert_ChangeType_SelfType_EqualsSelf() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(PowerRatio))); }
public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Equal(PowerRatio.Info, Convert.ChangeType(quantity, typeof(QuantityInfo))); }
public void ToUnit_WithNullUnitSystem_ThrowsNullException() { var decibelwatt = PowerRatio.FromDecibelWatts(1); Assert.Throws <ArgumentNullException>(() => decibelwatt.ToUnit(null)); }
public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = PowerRatio.FromDecibelWatts(1).ToBaseUnit(); Assert.Equal(PowerRatio.BaseUnit, quantityInBaseUnit.Unit); }
public void FromDecibelWatts_WithInfinityValue_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => PowerRatio.FromDecibelWatts(double.PositiveInfinity)); Assert.Throws <ArgumentException>(() => PowerRatio.FromDecibelWatts(double.NegativeInfinity)); }
public void FromDecibelWatts_WithNanValue_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => PowerRatio.FromDecibelWatts(double.NaN)); }
/// <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)); }
public void FromValueAndUnit() { AssertEx.EqualTolerance(1, PowerRatio.From(1, PowerRatioUnit.DecibelMilliwatt).DecibelMilliwatts, DecibelMilliwattsTolerance); AssertEx.EqualTolerance(1, PowerRatio.From(1, PowerRatioUnit.DecibelWatt).DecibelWatts, DecibelWattsTolerance); }
/// <inheritdoc cref="PowerRatio.FromDecibelWatts(UnitsNet.QuantityValue)" /> public static PowerRatio DecibelWatts <T>(this T value) => PowerRatio.FromDecibelWatts(Convert.ToDouble(value));
public void Convert_ToString_EqualsToString() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = PowerRatio.FromDecibelWatts(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(PowerRatio.FromDecibelWatts(1), -1, ComparisonType.Relative)); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void EqualsReturnsFalseOnNull() { PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); Assert.False(decibelwatt.Equals(null)); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PowerRatioUnit))); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null)); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Equal(PowerRatio.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void GetHashCode_Equals() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Equal(new { PowerRatio.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
/// <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)); }
public void Convert_ToInt32_EqualsValueAsSameType() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); }
public void CompareToThrowsOnTypeMismatch() { PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); Assert.Throws <ArgumentException>(() => decibelwatt.CompareTo(new object())); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = PowerRatio.FromDecibelWatts(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
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);