public void ArithmeticOperators()
        {
            SolidAngle v = SolidAngle.FromSteradians(1);

            AssertEx.EqualTolerance(-1, -v.Steradians, SteradiansTolerance);
            AssertEx.EqualTolerance(2, (SolidAngle.FromSteradians(3) - v).Steradians, SteradiansTolerance);
            AssertEx.EqualTolerance(2, (v + v).Steradians, SteradiansTolerance);
            AssertEx.EqualTolerance(10, (v * 10).Steradians, SteradiansTolerance);
            AssertEx.EqualTolerance(10, (10 * v).Steradians, SteradiansTolerance);
            AssertEx.EqualTolerance(2, (SolidAngle.FromSteradians(10) / 5).Steradians, SteradiansTolerance);
            AssertEx.EqualTolerance(2, SolidAngle.FromSteradians(10) / SolidAngle.FromSteradians(5), SteradiansTolerance);
        }
Ejemplo n.º 2
0
        public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
        {
            var steradian = SolidAngle.FromSteradians(1);

            Assert.Throws <ArgumentException>(() => steradian.ToUnit(UnitSystem.SI));
            Assert.Throws <ArgumentException>(() => steradian.ToUnit(UnitSystem.CGS));
            Assert.Throws <ArgumentException>(() => steradian.ToUnit(UnitSystem.BI));
            Assert.Throws <ArgumentException>(() => steradian.ToUnit(UnitSystem.EE));
            Assert.Throws <ArgumentException>(() => steradian.ToUnit(UnitSystem.USC));
            Assert.Throws <ArgumentException>(() => steradian.ToUnit(UnitSystem.FPS));
            Assert.Throws <ArgumentException>(() => steradian.ToUnit(UnitSystem.Astronomical));
        }
Ejemplo n.º 3
0
        public void EqualityOperators()
        {
            SolidAngle a = SolidAngle.FromSteradians(1);
            SolidAngle b = SolidAngle.FromSteradians(2);

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

            Assert.False(a == b);
            Assert.False(a != a);
// ReSharper restore EqualExpressionComparison
        }
Ejemplo n.º 4
0
        public void ComparisonOperators()
        {
            SolidAngle oneSteradian  = SolidAngle.FromSteradians(1);
            SolidAngle twoSteradians = SolidAngle.FromSteradians(2);

            Assert.True(oneSteradian < twoSteradians);
            Assert.True(oneSteradian <= twoSteradians);
            Assert.True(twoSteradians > oneSteradian);
            Assert.True(twoSteradians >= oneSteradian);

            Assert.False(oneSteradian > twoSteradians);
            Assert.False(oneSteradian >= twoSteradians);
            Assert.False(twoSteradians < oneSteradian);
            Assert.False(twoSteradians <= oneSteradian);
        }
Ejemplo n.º 5
0
        public void EqualityOperators()
        {
            var a = SolidAngle.FromSteradians(1);
            var b = SolidAngle.FromSteradians(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
        }
Ejemplo n.º 6
0
        public void CompareToThrowsOnTypeMismatch()
        {
            SolidAngle steradian = SolidAngle.FromSteradians(1);

            Assert.Throws <ArgumentException>(() => steradian.CompareTo(new object()));
        }
Ejemplo n.º 7
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = SolidAngle.FromSteradians(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
 /// <inheritdoc cref="SolidAngle.FromSteradians(double?)"/>
 public static SolidAngle?Steradians(this float?value) => SolidAngle.FromSteradians(value);
Ejemplo n.º 9
0
        public void As()
        {
            var steradian = SolidAngle.FromSteradians(1);

            AssertEx.EqualTolerance(SteradiansInOneSteradian, steradian.As(SolidAngleUnit.Steradian), SteradiansTolerance);
        }
Ejemplo n.º 10
0
 public void FromSteradians_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => SolidAngle.FromSteradians(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => SolidAngle.FromSteradians(double.NegativeInfinity));
 }
Ejemplo n.º 11
0
        public void EqualsReturnsFalseOnNull()
        {
            SolidAngle steradian = SolidAngle.FromSteradians(1);

            Assert.False(steradian.Equals(null));
        }
Ejemplo n.º 12
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = SolidAngle.FromSteradians(1.0);

            Assert.Equal(SolidAngle.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Ejemplo n.º 13
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = SolidAngle.FromSteradians(1.0);

            Assert.Equal(QuantityType.SolidAngle, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Ejemplo n.º 14
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = SolidAngle.FromSteradians(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SolidAngleUnit)));
        }
Ejemplo n.º 15
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = SolidAngle.FromSteradians(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(SolidAngle)));
        }
Ejemplo n.º 16
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = SolidAngle.FromSteradians(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Ejemplo n.º 17
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = SolidAngle.FromSteradians(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Ejemplo n.º 18
0
        public void CompareToThrowsOnNull()
        {
            SolidAngle steradian = SolidAngle.FromSteradians(1);

            Assert.Throws <ArgumentNullException>(() => steradian.CompareTo(null));
        }
Ejemplo n.º 19
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            SolidAngle steradian = SolidAngle.FromSteradians(1);

            Assert.False(steradian.Equals(new object()));
        }
Ejemplo n.º 20
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = SolidAngle.FromSteradians(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Ejemplo n.º 21
0
        public void SteradianToSolidAngleUnits()
        {
            SolidAngle steradian = SolidAngle.FromSteradians(1);

            AssertEx.EqualTolerance(SteradiansInOneSteradian, steradian.Steradians, SteradiansTolerance);
        }
Ejemplo n.º 22
0
        public void GetHashCode_Equals()
        {
            var quantity = SolidAngle.FromSteradians(1.0);

            Assert.Equal(new { SolidAngle.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Ejemplo n.º 23
0
 public void FromSteradians_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => SolidAngle.FromSteradians(double.NaN));
 }
Ejemplo n.º 24
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(decimal value)
        {
            var quantity = SolidAngle.FromSteradians(value);

            Assert.Equal(SolidAngle.FromSteradians(-value), -quantity);
        }
 /// <inheritdoc cref="SolidAngle.FromSteradians(double)"/>
 public static SolidAngle Steradians(this double value) => SolidAngle.FromSteradians(value);
 /// <inheritdoc cref="SolidAngle.FromSteradians(double?)"/>
 public static SolidAngle?Steradians(this decimal?value) => SolidAngle.FromSteradians(value == null ? (double?)null : Convert.ToDouble(value.Value));
 /// <inheritdoc cref="SolidAngle.FromSteradians(double)"/>
 public static SolidAngle Steradians(this decimal value) => SolidAngle.FromSteradians(Convert.ToDouble(value));
Ejemplo n.º 28
0
        public void Convert_ToInt16_EqualsValueAsSameType()
        {
            var quantity = SolidAngle.FromSteradians(1.0);

            Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity));
        }
 public void NumberToSteradiansTest() =>
 Assert.Equal(SolidAngle.FromSteradians(2), 2.Steradians());
Ejemplo n.º 30
0
        public void ConversionRoundTrip()
        {
            SolidAngle steradian = SolidAngle.FromSteradians(1);

            AssertEx.EqualTolerance(1, SolidAngle.FromSteradians(steradian.Steradians).Steradians, SteradiansTolerance);
        }