public void ToUnit() { var lux = Illuminance.FromLux(1); var footcandleQuantity = lux.ToUnit(IlluminanceUnit.FootCandle); AssertEx.EqualTolerance(FootCandlesInOneLux, (double)footcandleQuantity.Value, FootCandlesTolerance); Assert.Equal(IlluminanceUnit.FootCandle, footcandleQuantity.Unit); var kiloluxQuantity = lux.ToUnit(IlluminanceUnit.Kilolux); AssertEx.EqualTolerance(KiloluxInOneLux, (double)kiloluxQuantity.Value, KiloluxTolerance); Assert.Equal(IlluminanceUnit.Kilolux, kiloluxQuantity.Unit); var luxQuantity = lux.ToUnit(IlluminanceUnit.Lux); AssertEx.EqualTolerance(LuxInOneLux, (double)luxQuantity.Value, LuxTolerance); Assert.Equal(IlluminanceUnit.Lux, luxQuantity.Unit); var megaluxQuantity = lux.ToUnit(IlluminanceUnit.Megalux); AssertEx.EqualTolerance(MegaluxInOneLux, (double)megaluxQuantity.Value, MegaluxTolerance); Assert.Equal(IlluminanceUnit.Megalux, megaluxQuantity.Unit); var milliluxQuantity = lux.ToUnit(IlluminanceUnit.Millilux); AssertEx.EqualTolerance(MilliluxInOneLux, (double)milliluxQuantity.Value, MilliluxTolerance); Assert.Equal(IlluminanceUnit.Millilux, milliluxQuantity.Unit); }
public void As() { var lux = Illuminance.FromLux(1); AssertEx.EqualTolerance(CentiluxInOneLux, lux.As(IlluminanceUnit.Centilux), CentiluxTolerance); AssertEx.EqualTolerance(DecaluxInOneLux, lux.As(IlluminanceUnit.Decalux), DecaluxTolerance); AssertEx.EqualTolerance(DeciluxInOneLux, lux.As(IlluminanceUnit.Decilux), DeciluxTolerance); AssertEx.EqualTolerance(ExaluxInOneLux, lux.As(IlluminanceUnit.Exalux), ExaluxTolerance); AssertEx.EqualTolerance(FemtoluxInOneLux, lux.As(IlluminanceUnit.Femtolux), FemtoluxTolerance); AssertEx.EqualTolerance(GigaluxInOneLux, lux.As(IlluminanceUnit.Gigalux), GigaluxTolerance); AssertEx.EqualTolerance(HectoluxInOneLux, lux.As(IlluminanceUnit.Hectolux), HectoluxTolerance); AssertEx.EqualTolerance(KiloluxInOneLux, lux.As(IlluminanceUnit.Kilolux), KiloluxTolerance); AssertEx.EqualTolerance(LuxInOneLux, lux.As(IlluminanceUnit.Lux), LuxTolerance); AssertEx.EqualTolerance(MegaluxInOneLux, lux.As(IlluminanceUnit.Megalux), MegaluxTolerance); AssertEx.EqualTolerance(MicroluxInOneLux, lux.As(IlluminanceUnit.Microlux), MicroluxTolerance); AssertEx.EqualTolerance(MilliluxInOneLux, lux.As(IlluminanceUnit.Millilux), MilliluxTolerance); AssertEx.EqualTolerance(NanoluxInOneLux, lux.As(IlluminanceUnit.Nanolux), NanoluxTolerance); AssertEx.EqualTolerance(PetaluxInOneLux, lux.As(IlluminanceUnit.Petalux), PetaluxTolerance); AssertEx.EqualTolerance(PicoluxInOneLux, lux.As(IlluminanceUnit.Picolux), PicoluxTolerance); AssertEx.EqualTolerance(QutraluxInOneLux, lux.As(IlluminanceUnit.Qutralux), QutraluxTolerance); AssertEx.EqualTolerance(TeraluxInOneLux, lux.As(IlluminanceUnit.Teralux), TeraluxTolerance); AssertEx.EqualTolerance(VettaluxInOneLux, lux.As(IlluminanceUnit.Vettalux), VettaluxTolerance); AssertEx.EqualTolerance(YottaluxInOneLux, lux.As(IlluminanceUnit.Yottalux), YottaluxTolerance); AssertEx.EqualTolerance(ZettaluxInOneLux, lux.As(IlluminanceUnit.Zettalux), ZettaluxTolerance); }
public void ConversionRoundTrip() { Illuminance lux = Illuminance.FromLux(1); AssertEx.EqualTolerance(1, Illuminance.FromCentilux(lux.Centilux).Lux, CentiluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromDecalux(lux.Decalux).Lux, DecaluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromDecilux(lux.Decilux).Lux, DeciluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromExalux(lux.Exalux).Lux, ExaluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromFemtolux(lux.Femtolux).Lux, FemtoluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromGigalux(lux.Gigalux).Lux, GigaluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromHectolux(lux.Hectolux).Lux, HectoluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromKilolux(lux.Kilolux).Lux, KiloluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromLux(lux.Lux).Lux, LuxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromMegalux(lux.Megalux).Lux, MegaluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromMicrolux(lux.Microlux).Lux, MicroluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromMillilux(lux.Millilux).Lux, MilliluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromNanolux(lux.Nanolux).Lux, NanoluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromPetalux(lux.Petalux).Lux, PetaluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromPicolux(lux.Picolux).Lux, PicoluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromQutralux(lux.Qutralux).Lux, QutraluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromTeralux(lux.Teralux).Lux, TeraluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromVettalux(lux.Vettalux).Lux, VettaluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromYottalux(lux.Yottalux).Lux, YottaluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromZettalux(lux.Zettalux).Lux, ZettaluxTolerance); }
public void CompareToIsImplemented() { Illuminance lux = Illuminance.FromLux(1); Assert.Equal(0, lux.CompareTo(lux)); Assert.True(lux.CompareTo(Illuminance.Zero) > 0); Assert.True(Illuminance.Zero.CompareTo(lux) < 0); }
public void EqualsRelativeToleranceIsImplemented() { var v = Illuminance.FromLux(1); Assert.True(v.Equals(Illuminance.FromLux(1), LuxTolerance, ComparisonType.Relative)); Assert.False(v.Equals(Illuminance.Zero, LuxTolerance, ComparisonType.Relative)); }
public void LuxToIlluminanceUnits() { Illuminance lux = Illuminance.FromLux(1); AssertEx.EqualTolerance(CentiluxInOneLux, lux.Centilux, CentiluxTolerance); AssertEx.EqualTolerance(DecaluxInOneLux, lux.Decalux, DecaluxTolerance); AssertEx.EqualTolerance(DeciluxInOneLux, lux.Decilux, DeciluxTolerance); AssertEx.EqualTolerance(ExaluxInOneLux, lux.Exalux, ExaluxTolerance); AssertEx.EqualTolerance(FemtoluxInOneLux, lux.Femtolux, FemtoluxTolerance); AssertEx.EqualTolerance(GigaluxInOneLux, lux.Gigalux, GigaluxTolerance); AssertEx.EqualTolerance(HectoluxInOneLux, lux.Hectolux, HectoluxTolerance); AssertEx.EqualTolerance(KiloluxInOneLux, lux.Kilolux, KiloluxTolerance); AssertEx.EqualTolerance(LuxInOneLux, lux.Lux, LuxTolerance); AssertEx.EqualTolerance(MegaluxInOneLux, lux.Megalux, MegaluxTolerance); AssertEx.EqualTolerance(MicroluxInOneLux, lux.Microlux, MicroluxTolerance); AssertEx.EqualTolerance(MilliluxInOneLux, lux.Millilux, MilliluxTolerance); AssertEx.EqualTolerance(NanoluxInOneLux, lux.Nanolux, NanoluxTolerance); AssertEx.EqualTolerance(PetaluxInOneLux, lux.Petalux, PetaluxTolerance); AssertEx.EqualTolerance(PicoluxInOneLux, lux.Picolux, PicoluxTolerance); AssertEx.EqualTolerance(QutraluxInOneLux, lux.Qutralux, QutraluxTolerance); AssertEx.EqualTolerance(TeraluxInOneLux, lux.Teralux, TeraluxTolerance); AssertEx.EqualTolerance(VettaluxInOneLux, lux.Vettalux, VettaluxTolerance); AssertEx.EqualTolerance(YottaluxInOneLux, lux.Yottalux, YottaluxTolerance); AssertEx.EqualTolerance(ZettaluxInOneLux, lux.Zettalux, ZettaluxTolerance); }
public void EqualsIsImplemented() { Illuminance v = Illuminance.FromLux(1); Assert.True(v.Equals(Illuminance.FromLux(1), Illuminance.FromLux(LuxTolerance))); Assert.False(v.Equals(Illuminance.Zero, Illuminance.FromLux(LuxTolerance))); }
public void Equals_SameType_IsImplemented() { var a = Illuminance.FromLux(1); var b = Illuminance.FromLux(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); }
public void FromLux_WithInfinityValue_CreateQuantityAndAffectInfinityValue() { var positiveInfinityQuantity = Illuminance.FromLux(double.PositiveInfinity); var negativeInfinityQuantity = Illuminance.FromLux(double.NegativeInfinity); Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value)); Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value)); }
public void ConversionRoundTrip() { Illuminance lux = Illuminance.FromLux(1); AssertEx.EqualTolerance(1, Illuminance.FromKilolux(lux.Kilolux).Lux, KiloluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromLux(lux.Lux).Lux, LuxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromMegalux(lux.Megalux).Lux, MegaluxTolerance); AssertEx.EqualTolerance(1, Illuminance.FromMillilux(lux.Millilux).Lux, MilliluxTolerance); }
public void LuxToIlluminanceUnits() { Illuminance lux = Illuminance.FromLux(1); AssertEx.EqualTolerance(KiloluxInOneLux, lux.Kilolux, KiloluxTolerance); AssertEx.EqualTolerance(LuxInOneLux, lux.Lux, LuxTolerance); AssertEx.EqualTolerance(MegaluxInOneLux, lux.Megalux, MegaluxTolerance); AssertEx.EqualTolerance(MilliluxInOneLux, lux.Millilux, MilliluxTolerance); }
public void As() { var lux = Illuminance.FromLux(1); AssertEx.EqualTolerance(KiloluxInOneLux, lux.As(IlluminanceUnit.Kilolux), KiloluxTolerance); AssertEx.EqualTolerance(LuxInOneLux, lux.As(IlluminanceUnit.Lux), LuxTolerance); AssertEx.EqualTolerance(MegaluxInOneLux, lux.As(IlluminanceUnit.Megalux), MegaluxTolerance); AssertEx.EqualTolerance(MilliluxInOneLux, lux.As(IlluminanceUnit.Millilux), MilliluxTolerance); }
public void Equals_QuantityAsObject_IsImplemented() { object a = Illuminance.FromLux(1); object b = Illuminance.FromLux(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals((object)null)); }
public void ArithmeticOperators() { Illuminance v = Illuminance.FromLux(1); AssertEx.EqualTolerance(-1, -v.Lux, LuxTolerance); AssertEx.EqualTolerance(2, (Illuminance.FromLux(3)-v).Lux, LuxTolerance); AssertEx.EqualTolerance(2, (v + v).Lux, LuxTolerance); AssertEx.EqualTolerance(10, (v*10).Lux, LuxTolerance); AssertEx.EqualTolerance(10, (10*v).Lux, LuxTolerance); AssertEx.EqualTolerance(2, (Illuminance.FromLux(10)/5).Lux, LuxTolerance); AssertEx.EqualTolerance(2, Illuminance.FromLux(10)/Illuminance.FromLux(5), LuxTolerance); }
public void EqualityOperators() { Illuminance a = Illuminance.FromLux(1); Illuminance b = Illuminance.FromLux(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() { Illuminance oneLux = Illuminance.FromLux(1); Illuminance twoLux = Illuminance.FromLux(2); Assert.True(oneLux < twoLux); Assert.True(oneLux <= twoLux); Assert.True(twoLux > oneLux); Assert.True(twoLux >= oneLux); Assert.False(oneLux > twoLux); Assert.False(oneLux >= twoLux); Assert.False(twoLux < oneLux); Assert.False(twoLux <= oneLux); }
public void EqualityOperators() { var a = Illuminance.FromLux(1); var b = Illuminance.FromLux(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 lux = Illuminance.FromLux(1); var kiloluxQuantity = lux.ToUnit(IlluminanceUnit.Kilolux); AssertEx.EqualTolerance(KiloluxInOneLux, (decimal)kiloluxQuantity.Value, KiloluxTolerance); Assert.Equal(IlluminanceUnit.Kilolux, kiloluxQuantity.Unit); var luxQuantity = lux.ToUnit(IlluminanceUnit.Lux); AssertEx.EqualTolerance(LuxInOneLux, (decimal)luxQuantity.Value, LuxTolerance); Assert.Equal(IlluminanceUnit.Lux, luxQuantity.Unit); var megaluxQuantity = lux.ToUnit(IlluminanceUnit.Megalux); AssertEx.EqualTolerance(MegaluxInOneLux, (decimal)megaluxQuantity.Value, MegaluxTolerance); Assert.Equal(IlluminanceUnit.Megalux, megaluxQuantity.Unit); var milliluxQuantity = lux.ToUnit(IlluminanceUnit.Millilux); AssertEx.EqualTolerance(MilliluxInOneLux, (decimal)milliluxQuantity.Value, MilliluxTolerance); Assert.Equal(IlluminanceUnit.Millilux, milliluxQuantity.Unit); }
public void CompareToThrowsOnNull() { Illuminance lux = Illuminance.FromLux(1); Assert.Throws <ArgumentNullException>(() => lux.CompareTo(null)); }
public void CompareToThrowsOnTypeMismatch() { Illuminance lux = Illuminance.FromLux(1); Assert.Throws <ArgumentException>(() => lux.CompareTo(new object())); }
public void ToUnit() { var lux = Illuminance.FromLux(1); var centiluxQuantity = lux.ToUnit(IlluminanceUnit.Centilux); AssertEx.EqualTolerance(CentiluxInOneLux, (double)centiluxQuantity.Value, CentiluxTolerance); Assert.Equal(IlluminanceUnit.Centilux, centiluxQuantity.Unit); var decaluxQuantity = lux.ToUnit(IlluminanceUnit.Decalux); AssertEx.EqualTolerance(DecaluxInOneLux, (double)decaluxQuantity.Value, DecaluxTolerance); Assert.Equal(IlluminanceUnit.Decalux, decaluxQuantity.Unit); var deciluxQuantity = lux.ToUnit(IlluminanceUnit.Decilux); AssertEx.EqualTolerance(DeciluxInOneLux, (double)deciluxQuantity.Value, DeciluxTolerance); Assert.Equal(IlluminanceUnit.Decilux, deciluxQuantity.Unit); var exaluxQuantity = lux.ToUnit(IlluminanceUnit.Exalux); AssertEx.EqualTolerance(ExaluxInOneLux, (double)exaluxQuantity.Value, ExaluxTolerance); Assert.Equal(IlluminanceUnit.Exalux, exaluxQuantity.Unit); var femtoluxQuantity = lux.ToUnit(IlluminanceUnit.Femtolux); AssertEx.EqualTolerance(FemtoluxInOneLux, (double)femtoluxQuantity.Value, FemtoluxTolerance); Assert.Equal(IlluminanceUnit.Femtolux, femtoluxQuantity.Unit); var gigaluxQuantity = lux.ToUnit(IlluminanceUnit.Gigalux); AssertEx.EqualTolerance(GigaluxInOneLux, (double)gigaluxQuantity.Value, GigaluxTolerance); Assert.Equal(IlluminanceUnit.Gigalux, gigaluxQuantity.Unit); var hectoluxQuantity = lux.ToUnit(IlluminanceUnit.Hectolux); AssertEx.EqualTolerance(HectoluxInOneLux, (double)hectoluxQuantity.Value, HectoluxTolerance); Assert.Equal(IlluminanceUnit.Hectolux, hectoluxQuantity.Unit); var kiloluxQuantity = lux.ToUnit(IlluminanceUnit.Kilolux); AssertEx.EqualTolerance(KiloluxInOneLux, (double)kiloluxQuantity.Value, KiloluxTolerance); Assert.Equal(IlluminanceUnit.Kilolux, kiloluxQuantity.Unit); var luxQuantity = lux.ToUnit(IlluminanceUnit.Lux); AssertEx.EqualTolerance(LuxInOneLux, (double)luxQuantity.Value, LuxTolerance); Assert.Equal(IlluminanceUnit.Lux, luxQuantity.Unit); var megaluxQuantity = lux.ToUnit(IlluminanceUnit.Megalux); AssertEx.EqualTolerance(MegaluxInOneLux, (double)megaluxQuantity.Value, MegaluxTolerance); Assert.Equal(IlluminanceUnit.Megalux, megaluxQuantity.Unit); var microluxQuantity = lux.ToUnit(IlluminanceUnit.Microlux); AssertEx.EqualTolerance(MicroluxInOneLux, (double)microluxQuantity.Value, MicroluxTolerance); Assert.Equal(IlluminanceUnit.Microlux, microluxQuantity.Unit); var milliluxQuantity = lux.ToUnit(IlluminanceUnit.Millilux); AssertEx.EqualTolerance(MilliluxInOneLux, (double)milliluxQuantity.Value, MilliluxTolerance); Assert.Equal(IlluminanceUnit.Millilux, milliluxQuantity.Unit); var nanoluxQuantity = lux.ToUnit(IlluminanceUnit.Nanolux); AssertEx.EqualTolerance(NanoluxInOneLux, (double)nanoluxQuantity.Value, NanoluxTolerance); Assert.Equal(IlluminanceUnit.Nanolux, nanoluxQuantity.Unit); var petaluxQuantity = lux.ToUnit(IlluminanceUnit.Petalux); AssertEx.EqualTolerance(PetaluxInOneLux, (double)petaluxQuantity.Value, PetaluxTolerance); Assert.Equal(IlluminanceUnit.Petalux, petaluxQuantity.Unit); var picoluxQuantity = lux.ToUnit(IlluminanceUnit.Picolux); AssertEx.EqualTolerance(PicoluxInOneLux, (double)picoluxQuantity.Value, PicoluxTolerance); Assert.Equal(IlluminanceUnit.Picolux, picoluxQuantity.Unit); var qutraluxQuantity = lux.ToUnit(IlluminanceUnit.Qutralux); AssertEx.EqualTolerance(QutraluxInOneLux, (double)qutraluxQuantity.Value, QutraluxTolerance); Assert.Equal(IlluminanceUnit.Qutralux, qutraluxQuantity.Unit); var teraluxQuantity = lux.ToUnit(IlluminanceUnit.Teralux); AssertEx.EqualTolerance(TeraluxInOneLux, (double)teraluxQuantity.Value, TeraluxTolerance); Assert.Equal(IlluminanceUnit.Teralux, teraluxQuantity.Unit); var vettaluxQuantity = lux.ToUnit(IlluminanceUnit.Vettalux); AssertEx.EqualTolerance(VettaluxInOneLux, (double)vettaluxQuantity.Value, VettaluxTolerance); Assert.Equal(IlluminanceUnit.Vettalux, vettaluxQuantity.Unit); var yottaluxQuantity = lux.ToUnit(IlluminanceUnit.Yottalux); AssertEx.EqualTolerance(YottaluxInOneLux, (double)yottaluxQuantity.Value, YottaluxTolerance); Assert.Equal(IlluminanceUnit.Yottalux, yottaluxQuantity.Unit); var zettaluxQuantity = lux.ToUnit(IlluminanceUnit.Zettalux); AssertEx.EqualTolerance(ZettaluxInOneLux, (double)zettaluxQuantity.Value, ZettaluxTolerance); Assert.Equal(IlluminanceUnit.Zettalux, zettaluxQuantity.Unit); }
/// <inheritdoc cref="Illuminance.FromLux(double?)"/> public static Illuminance?Lux(this double?value) => Illuminance.FromLux(value);
public void FromLux_WithInfinityValue_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => Illuminance.FromLux(double.PositiveInfinity)); Assert.Throws <ArgumentException>(() => Illuminance.FromLux(double.NegativeInfinity)); }
public static Illuminance?Lux <T>(this T?value) where T : struct => Illuminance.FromLux(value == null ? (double?)null : Convert.ToDouble(value.Value));
public void EqualsReturnsFalseOnNull() { Illuminance lux = Illuminance.FromLux(1); Assert.False(lux.Equals(null)); }
public void FromLux_WithNanValue_ThrowsArgumentException() { Assert.Throws <ArgumentException>(() => Illuminance.FromLux(double.NaN)); }
public void EqualsReturnsFalseOnTypeMismatch() { Illuminance lux = Illuminance.FromLux(1); Assert.False(lux.Equals(new object())); }
/// <inheritdoc cref="Illuminance.FromLux(double?)"/> public static Illuminance?Lux(this long?value) => Illuminance.FromLux(value);
public void NumberToLuxTest() => Assert.Equal(Illuminance.FromLux(2), 2.Lux());
/// <inheritdoc cref="Illuminance.FromLux(UnitsNet.QuantityValue)" /> public static Illuminance Lux <T>(this T value) => Illuminance.FromLux(Convert.ToDouble(value));