Exemplo n.º 1
0
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = Luminance.FromCandelaPerSquareMeters(1);

            Assert.True(v.Equals(Luminance.FromCandelaPerSquareMeters(1), CandelaPerSquareMetersTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(Luminance.Zero, CandelaPerSquareMetersTolerance, ComparisonType.Relative));
        }
Exemplo n.º 2
0
        public void CandelaPerSquareMeterToLuminanceUnits()
        {
            Luminance candelapersquaremeter = Luminance.FromCandelaPerSquareMeters(1);

            AssertEx.EqualTolerance(CandelaPerSquareMetersInOneCandelaPerSquareMeter, candelapersquaremeter.CandelaPerSquareMeters, CandelaPerSquareMetersTolerance);
            AssertEx.EqualTolerance(FootLambertsInOneCandelaPerSquareMeter, candelapersquaremeter.FootLamberts, FootLambertsTolerance);
        }
Exemplo n.º 3
0
        public void As()
        {
            var candelapersquaremeter = Luminance.FromCandelaPerSquareMeters(1);

            AssertEx.EqualTolerance(CandelaPerSquareMetersInOneCandelaPerSquareMeter, candelapersquaremeter.As(LuminanceUnit.CandelaPerSquareMeter), CandelaPerSquareMetersTolerance);
            AssertEx.EqualTolerance(FootLambertsInOneCandelaPerSquareMeter, candelapersquaremeter.As(LuminanceUnit.FootLambert), FootLambertsTolerance);
        }
Exemplo n.º 4
0
        public void ConversionRoundTrip()
        {
            Luminance candelapersquaremeter = Luminance.FromCandelaPerSquareMeters(1);

            AssertEx.EqualTolerance(1, Luminance.FromCandelaPerSquareMeters(candelapersquaremeter.CandelaPerSquareMeters).CandelaPerSquareMeters, CandelaPerSquareMetersTolerance);
            AssertEx.EqualTolerance(1, Luminance.FromFootLamberts(candelapersquaremeter.FootLamberts).CandelaPerSquareMeters, FootLambertsTolerance);
        }
Exemplo n.º 5
0
        public void Equals_SameType_IsImplemented()
        {
            var a = Luminance.FromCandelaPerSquareMeters(1);
            var b = Luminance.FromCandelaPerSquareMeters(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
Exemplo n.º 6
0
        public void CompareToIsImplemented()
        {
            Luminance candelapersquaremeter = Luminance.FromCandelaPerSquareMeters(1);

            Assert.Equal(0, candelapersquaremeter.CompareTo(candelapersquaremeter));
            Assert.True(candelapersquaremeter.CompareTo(Luminance.Zero) > 0);
            Assert.True(Luminance.Zero.CompareTo(candelapersquaremeter) < 0);
        }
Exemplo n.º 7
0
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = Luminance.FromCandelaPerSquareMeters(1);
            object b = Luminance.FromCandelaPerSquareMeters(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
Exemplo n.º 8
0
        public void ArithmeticOperators()
        {
            Luminance v = Luminance.FromCandelaPerSquareMeters(1);

            AssertEx.EqualTolerance(-1, -v.CandelaPerSquareMeters, CandelaPerSquareMetersTolerance);
            AssertEx.EqualTolerance(2, (Luminance.FromCandelaPerSquareMeters(3) - v).CandelaPerSquareMeters, CandelaPerSquareMetersTolerance);
            AssertEx.EqualTolerance(2, (v + v).CandelaPerSquareMeters, CandelaPerSquareMetersTolerance);
            AssertEx.EqualTolerance(10, (v * 10).CandelaPerSquareMeters, CandelaPerSquareMetersTolerance);
            AssertEx.EqualTolerance(10, (10 * v).CandelaPerSquareMeters, CandelaPerSquareMetersTolerance);
            AssertEx.EqualTolerance(2, (Luminance.FromCandelaPerSquareMeters(10) / 5).CandelaPerSquareMeters, CandelaPerSquareMetersTolerance);
            AssertEx.EqualTolerance(2, Luminance.FromCandelaPerSquareMeters(10) / Luminance.FromCandelaPerSquareMeters(5), CandelaPerSquareMetersTolerance);
        }
Exemplo n.º 9
0
        public void ToUnit()
        {
            var candelapersquaremeter = Luminance.FromCandelaPerSquareMeters(1);

            var candelapersquaremeterQuantity = candelapersquaremeter.ToUnit(LuminanceUnit.CandelaPerSquareMeter);

            AssertEx.EqualTolerance(CandelaPerSquareMetersInOneCandelaPerSquareMeter, (double)candelapersquaremeterQuantity.Value, CandelaPerSquareMetersTolerance);
            Assert.Equal(LuminanceUnit.CandelaPerSquareMeter, candelapersquaremeterQuantity.Unit);

            var footlambertQuantity = candelapersquaremeter.ToUnit(LuminanceUnit.FootLambert);

            AssertEx.EqualTolerance(FootLambertsInOneCandelaPerSquareMeter, (double)footlambertQuantity.Value, FootLambertsTolerance);
            Assert.Equal(LuminanceUnit.FootLambert, footlambertQuantity.Unit);
        }
Exemplo n.º 10
0
        public void ComparisonOperators()
        {
            Luminance oneCandelaPerSquareMeter  = Luminance.FromCandelaPerSquareMeters(1);
            Luminance twoCandelaPerSquareMeters = Luminance.FromCandelaPerSquareMeters(2);

            Assert.True(oneCandelaPerSquareMeter < twoCandelaPerSquareMeters);
            Assert.True(oneCandelaPerSquareMeter <= twoCandelaPerSquareMeters);
            Assert.True(twoCandelaPerSquareMeters > oneCandelaPerSquareMeter);
            Assert.True(twoCandelaPerSquareMeters >= oneCandelaPerSquareMeter);

            Assert.False(oneCandelaPerSquareMeter > twoCandelaPerSquareMeters);
            Assert.False(oneCandelaPerSquareMeter >= twoCandelaPerSquareMeters);
            Assert.False(twoCandelaPerSquareMeters < oneCandelaPerSquareMeter);
            Assert.False(twoCandelaPerSquareMeters <= oneCandelaPerSquareMeter);
        }
Exemplo n.º 11
0
        public void EqualityOperators()
        {
            var a = Luminance.FromCandelaPerSquareMeters(1);
            var b = Luminance.FromCandelaPerSquareMeters(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
        }
Exemplo n.º 12
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Exemplo n.º 13
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Exemplo n.º 14
0
        public void GetHashCode_Equals()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal(new { Luminance.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Exemplo n.º 15
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal(Luminance.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Exemplo n.º 16
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Exemplo n.º 17
0
        public void CompareToThrowsOnNull()
        {
            Luminance candelapersquaremeter = Luminance.FromCandelaPerSquareMeters(1);

            Assert.Throws <ArgumentNullException>(() => candelapersquaremeter.CompareTo(null));
        }
Exemplo n.º 18
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
Exemplo n.º 19
0
        public void Convert_ToInt16_EqualsValueAsSameType()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity));
        }
Exemplo n.º 20
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Exemplo n.º 21
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Exemplo n.º 22
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LuminanceUnit)));
        }
Exemplo n.º 23
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(Luminance)));
        }
Exemplo n.º 24
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = Luminance.FromCandelaPerSquareMeters(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(Luminance.FromCandelaPerSquareMeters(1), -1, ComparisonType.Relative));
        }
Exemplo n.º 25
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Equal(QuantityType.Luminance, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Exemplo n.º 26
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            Luminance candelapersquaremeter = Luminance.FromCandelaPerSquareMeters(1);

            Assert.False(candelapersquaremeter.Equals(new object()));
        }
Exemplo n.º 27
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Exemplo n.º 28
0
        public void EqualsReturnsFalseOnNull()
        {
            Luminance candelapersquaremeter = Luminance.FromCandelaPerSquareMeters(1);

            Assert.False(candelapersquaremeter.Equals(null));
        }
Exemplo n.º 29
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(value);

            Assert.Equal(Luminance.FromCandelaPerSquareMeters(-value), -quantity);
        }
Exemplo n.º 30
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = Luminance.FromCandelaPerSquareMeters(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }