示例#1
0
        public void EqualsIsImplemented()
        {
            ElectricCurrentDensity v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            Assert.True(v.Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(1), ElectricCurrentDensity.FromAmperesPerSquareMeter(AmperesPerSquareMeterTolerance)));
            Assert.False(v.Equals(ElectricCurrentDensity.Zero, ElectricCurrentDensity.FromAmperesPerSquareMeter(AmperesPerSquareMeterTolerance)));
        }
示例#2
0
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            Assert.True(v.Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(1), AmperesPerSquareMeterTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(ElectricCurrentDensity.Zero, AmperesPerSquareMeterTolerance, ComparisonType.Relative));
        }
示例#3
0
        public void Equals_SameType_IsImplemented()
        {
            var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
            var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
示例#4
0
        public void ConversionRoundTrip()
        {
            ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareFoot(amperepersquaremeter.AmperesPerSquareFoot).AmperesPerSquareMeter, AmperesPerSquareFootTolerance);
            AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareInch(amperepersquaremeter.AmperesPerSquareInch).AmperesPerSquareMeter, AmperesPerSquareInchTolerance);
            AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareMeter(amperepersquaremeter.AmperesPerSquareMeter).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
        }
示例#5
0
        public void CompareToIsImplemented()
        {
            ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            Assert.Equal(0, amperepersquaremeter.CompareTo(amperepersquaremeter));
            Assert.True(amperepersquaremeter.CompareTo(ElectricCurrentDensity.Zero) > 0);
            Assert.True(ElectricCurrentDensity.Zero.CompareTo(amperepersquaremeter) < 0);
        }
示例#6
0
        public void As()
        {
            var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            AssertEx.EqualTolerance(AmperesPerSquareFootInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareFoot), AmperesPerSquareFootTolerance);
            AssertEx.EqualTolerance(AmperesPerSquareInchInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareInch), AmperesPerSquareInchTolerance);
            AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareMeter), AmperesPerSquareMeterTolerance);
        }
        public void FromAmperesPerSquareMeter_WithInfinityValue_CreateQuantityAndAffectInfinityValue()
        {
            var positiveInfinityQuantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(double.PositiveInfinity);
            var negativeInfinityQuantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(double.NegativeInfinity);

            Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value));
            Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value));
        }
示例#8
0
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
            object b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
示例#9
0
        public void ToUnit()
        {
            var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            var amperepersquaremeterQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareMeter);

            AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, (double)amperepersquaremeterQuantity.Value, AmperesPerSquareMeterTolerance);
            Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, amperepersquaremeterQuantity.Unit);
        }
示例#10
0
        public void ArithmeticOperators()
        {
            ElectricCurrentDensity v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            AssertEx.EqualTolerance(-1, -v.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
            AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(3) - v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
            AssertEx.EqualTolerance(2, (v + v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
            AssertEx.EqualTolerance(10, (v * 10).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
            AssertEx.EqualTolerance(10, (10 * v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
            AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(10) / 5).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
            AssertEx.EqualTolerance(2, ElectricCurrentDensity.FromAmperesPerSquareMeter(10) / ElectricCurrentDensity.FromAmperesPerSquareMeter(5), AmperesPerSquareMeterTolerance);
        }
示例#11
0
        public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
        {
            var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.SI));
            Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.CGS));
            Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.BI));
            Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.EE));
            Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.USC));
            Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.FPS));
            Assert.Throws <ArgumentException>(() => amperepersquaremeter.ToUnit(UnitSystem.Astronomical));
        }
示例#12
0
        public void EqualityOperators()
        {
            ElectricCurrentDensity a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
            ElectricCurrentDensity b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2);

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

            Assert.False(a == b);
            Assert.False(a != a);
// ReSharper restore EqualExpressionComparison
        }
示例#13
0
        public void ComparisonOperators()
        {
            ElectricCurrentDensity oneAmperePerSquareMeter  = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
            ElectricCurrentDensity twoAmperesPerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(2);

            Assert.True(oneAmperePerSquareMeter < twoAmperesPerSquareMeter);
            Assert.True(oneAmperePerSquareMeter <= twoAmperesPerSquareMeter);
            Assert.True(twoAmperesPerSquareMeter > oneAmperePerSquareMeter);
            Assert.True(twoAmperesPerSquareMeter >= oneAmperePerSquareMeter);

            Assert.False(oneAmperePerSquareMeter > twoAmperesPerSquareMeter);
            Assert.False(oneAmperePerSquareMeter >= twoAmperesPerSquareMeter);
            Assert.False(twoAmperesPerSquareMeter < oneAmperePerSquareMeter);
            Assert.False(twoAmperesPerSquareMeter <= oneAmperePerSquareMeter);
        }
示例#14
0
        public void ToUnit()
        {
            var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            var amperepersquarefootQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareFoot);

            AssertEx.EqualTolerance(AmperesPerSquareFootInOneAmperePerSquareMeter, (decimal)amperepersquarefootQuantity.Value, AmperesPerSquareFootTolerance);
            Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareFoot, amperepersquarefootQuantity.Unit);

            var amperepersquareinchQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareInch);

            AssertEx.EqualTolerance(AmperesPerSquareInchInOneAmperePerSquareMeter, (decimal)amperepersquareinchQuantity.Value, AmperesPerSquareInchTolerance);
            Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareInch, amperepersquareinchQuantity.Unit);

            var amperepersquaremeterQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareMeter);

            AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, (decimal)amperepersquaremeterQuantity.Value, AmperesPerSquareMeterTolerance);
            Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, amperepersquaremeterQuantity.Unit);
        }
示例#15
0
        public void EqualityOperators()
        {
            var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
            var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(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
        }
示例#16
0
        public void CompareToThrowsOnNull()
        {
            ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            Assert.Throws <ArgumentNullException>(() => amperepersquaremeter.CompareTo(null));
        }
示例#17
0
        public void CompareToThrowsOnTypeMismatch()
        {
            ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            Assert.Throws <ArgumentException>(() => amperepersquaremeter.CompareTo(new object()));
        }
示例#18
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0);

            Assert.Equal(ElectricCurrentDensity.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
示例#19
0
        public void EqualsReturnsFalseOnNull()
        {
            ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            Assert.False(amperepersquaremeter.Equals(null));
        }
示例#20
0
 /// <inheritdoc cref="ElectricCurrentDensity.FromAmperesPerSquareMeter(double?)"/>
 public static ElectricCurrentDensity?AmperesPerSquareMeter(this float?value) => ElectricCurrentDensity.FromAmperesPerSquareMeter(value);
示例#21
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(decimal value)
        {
            var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value);

            Assert.Equal(ElectricCurrentDensity.FromAmperesPerSquareMeter(-value), -quantity);
        }
示例#22
0
        public void GetHashCode_Equals()
        {
            var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0);

            Assert.Equal(new { ElectricCurrentDensity.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
示例#23
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
示例#24
0
 /// <inheritdoc cref="ElectricCurrentDensity.FromAmperesPerSquareMeter(double)"/>
 public static ElectricCurrentDensity AmperesPerSquareMeter(this decimal value) => ElectricCurrentDensity.FromAmperesPerSquareMeter(Convert.ToDouble(value));
示例#25
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            Assert.False(amperepersquaremeter.Equals(new object()));
        }
示例#26
0
 /// <inheritdoc cref="ElectricCurrentDensity.FromAmperesPerSquareMeter(double?)"/>
 public static ElectricCurrentDensity?AmperesPerSquareMeter(this decimal?value) => ElectricCurrentDensity.FromAmperesPerSquareMeter(value == null ? (double?)null : Convert.ToDouble(value.Value));
示例#27
0
        public void AmperePerSquareMeterToElectricCurrentDensityUnits()
        {
            ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);

            AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
        }
示例#28
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0);

            Assert.Equal(QuantityType.ElectricCurrentDensity, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
 public void NumberToAmperesPerSquareMeterTest() =>
 Assert.Equal(ElectricCurrentDensity.FromAmperesPerSquareMeter(2), 2.AmperesPerSquareMeter());
示例#30
0
 /// <inheritdoc cref="ElectricCurrentDensity.FromAmperesPerSquareMeter(double)"/>
 public static ElectricCurrentDensity AmperesPerSquareMeter(this double value) => ElectricCurrentDensity.FromAmperesPerSquareMeter(value);