Пример #1
0
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = Radiance.FromWattPerSquareMeterSteradians(1);

            Assert.True(v.Equals(Radiance.FromWattPerSquareMeterSteradians(1), WattPerSquareMeterSteradiansTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(Radiance.Zero, WattPerSquareMeterSteradiansTolerance, ComparisonType.Relative));
        }
Пример #2
0
        public void Equals_SameType_IsImplemented()
        {
            var a = Radiance.FromWattPerSquareMeterSteradians(1);
            var b = Radiance.FromWattPerSquareMeterSteradians(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
Пример #3
0
        public void CompareToIsImplemented()
        {
            Radiance wattpersquaremetersteradian = Radiance.FromWattPerSquareMeterSteradians(1);

            Assert.Equal(0, wattpersquaremetersteradian.CompareTo(wattpersquaremetersteradian));
            Assert.True(wattpersquaremetersteradian.CompareTo(Radiance.Zero) > 0);
            Assert.True(Radiance.Zero.CompareTo(wattpersquaremetersteradian) < 0);
        }
Пример #4
0
        public void ToUnit()
        {
            var wattpersquaremetersteradian = Radiance.FromWattPerSquareMeterSteradians(1);

            var wattpersquaremetersteradianQuantity = wattpersquaremetersteradian.ToUnit(RadianceUnit.WattPerSquareMeterSteradian);

            AssertEx.EqualTolerance(WattPerSquareMeterSteradiansInOneWattPerSquareMeterSteradian, (double)wattpersquaremetersteradianQuantity.Value, WattPerSquareMeterSteradiansTolerance);
            Assert.Equal(RadianceUnit.WattPerSquareMeterSteradian, wattpersquaremetersteradianQuantity.Unit);
        }
Пример #5
0
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = Radiance.FromWattPerSquareMeterSteradians(1);
            object b = Radiance.FromWattPerSquareMeterSteradians(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
Пример #6
0
        public void ArithmeticOperators()
        {
            Radiance v = Radiance.FromWattPerSquareMeterSteradians(1);

            AssertEx.EqualTolerance(-1, -v.WattPerSquareMeterSteradians, WattPerSquareMeterSteradiansTolerance);
            AssertEx.EqualTolerance(2, (Radiance.FromWattPerSquareMeterSteradians(3) - v).WattPerSquareMeterSteradians, WattPerSquareMeterSteradiansTolerance);
            AssertEx.EqualTolerance(2, (v + v).WattPerSquareMeterSteradians, WattPerSquareMeterSteradiansTolerance);
            AssertEx.EqualTolerance(10, (v * 10).WattPerSquareMeterSteradians, WattPerSquareMeterSteradiansTolerance);
            AssertEx.EqualTolerance(10, (10 * v).WattPerSquareMeterSteradians, WattPerSquareMeterSteradiansTolerance);
            AssertEx.EqualTolerance(2, (Radiance.FromWattPerSquareMeterSteradians(10) / 5).WattPerSquareMeterSteradians, WattPerSquareMeterSteradiansTolerance);
            AssertEx.EqualTolerance(2, Radiance.FromWattPerSquareMeterSteradians(10) / Radiance.FromWattPerSquareMeterSteradians(5), WattPerSquareMeterSteradiansTolerance);
        }
Пример #7
0
        public void ComparisonOperators()
        {
            Radiance oneWattPerSquareMeterSteradian  = Radiance.FromWattPerSquareMeterSteradians(1);
            Radiance twoWattPerSquareMeterSteradians = Radiance.FromWattPerSquareMeterSteradians(2);

            Assert.True(oneWattPerSquareMeterSteradian < twoWattPerSquareMeterSteradians);
            Assert.True(oneWattPerSquareMeterSteradian <= twoWattPerSquareMeterSteradians);
            Assert.True(twoWattPerSquareMeterSteradians > oneWattPerSquareMeterSteradian);
            Assert.True(twoWattPerSquareMeterSteradians >= oneWattPerSquareMeterSteradian);

            Assert.False(oneWattPerSquareMeterSteradian > twoWattPerSquareMeterSteradians);
            Assert.False(oneWattPerSquareMeterSteradian >= twoWattPerSquareMeterSteradians);
            Assert.False(twoWattPerSquareMeterSteradians < oneWattPerSquareMeterSteradian);
            Assert.False(twoWattPerSquareMeterSteradians <= oneWattPerSquareMeterSteradian);
        }
Пример #8
0
        public void EqualityOperators()
        {
            var a = Radiance.FromWattPerSquareMeterSteradians(1);
            var b = Radiance.FromWattPerSquareMeterSteradians(2);

            // 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
        }
Пример #9
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Пример #10
0
        public void Convert_ToInt16_EqualsValueAsSameType()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity));
        }
Пример #11
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
Пример #12
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Пример #13
0
        public void ConversionRoundTrip()
        {
            Radiance wattpersquaremetersteradian = Radiance.FromWattPerSquareMeterSteradians(1);

            AssertEx.EqualTolerance(1, Radiance.FromWattPerSquareMeterSteradians(wattpersquaremetersteradian.WattPerSquareMeterSteradians).WattPerSquareMeterSteradians, WattPerSquareMeterSteradiansTolerance);
        }
Пример #14
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(value);

            Assert.Equal(Radiance.FromWattPerSquareMeterSteradians(-value), -quantity);
        }
Пример #15
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Пример #16
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal(QuantityType.Radiance, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Пример #17
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(Radiance)));
        }
Пример #18
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Пример #19
0
        public void CompareToThrowsOnNull()
        {
            Radiance wattpersquaremetersteradian = Radiance.FromWattPerSquareMeterSteradians(1);

            Assert.Throws <ArgumentNullException>(() => wattpersquaremetersteradian.CompareTo(null));
        }
Пример #20
0
        public void CompareToThrowsOnTypeMismatch()
        {
            Radiance wattpersquaremetersteradian = Radiance.FromWattPerSquareMeterSteradians(1);

            Assert.Throws <ArgumentException>(() => wattpersquaremetersteradian.CompareTo(new object()));
        }
Пример #21
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Пример #22
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = Radiance.FromWattPerSquareMeterSteradians(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(Radiance.FromWattPerSquareMeterSteradians(1), -1, ComparisonType.Relative));
        }
Пример #23
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RadianceUnit)));
        }
Пример #24
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            Radiance wattpersquaremetersteradian = Radiance.FromWattPerSquareMeterSteradians(1);

            Assert.False(wattpersquaremetersteradian.Equals(new object()));
        }
Пример #25
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal(Radiance.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Пример #26
0
        public void EqualsReturnsFalseOnNull()
        {
            Radiance wattpersquaremetersteradian = Radiance.FromWattPerSquareMeterSteradians(1);

            Assert.False(wattpersquaremetersteradian.Equals(null));
        }
Пример #27
0
        public void GetHashCode_Equals()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal(new { Radiance.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Пример #28
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
 public void NumberToWattPerSquareMeterSteradiansTest() =>
 Assert.Equal(Radiance.FromWattPerSquareMeterSteradians(2), 2.WattPerSquareMeterSteradians());
Пример #30
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = Radiance.FromWattPerSquareMeterSteradians(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }