Ejemplo n.º 1
0
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = ElectricConductance.FromSiemens(1);

            Assert.True(v.Equals(ElectricConductance.FromSiemens(1), SiemensTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(ElectricConductance.Zero, SiemensTolerance, ComparisonType.Relative));
        }
Ejemplo n.º 2
0
        public void EqualsIsImplemented()
        {
            ElectricConductance v = ElectricConductance.FromSiemens(1);

            Assert.True(v.Equals(ElectricConductance.FromSiemens(1), ElectricConductance.FromSiemens(SiemensTolerance)));
            Assert.False(v.Equals(ElectricConductance.Zero, ElectricConductance.FromSiemens(SiemensTolerance)));
        }
Ejemplo n.º 3
0
        public void ConversionRoundTrip()
        {
            ElectricConductance siemens = ElectricConductance.FromSiemens(1);

            AssertEx.EqualTolerance(1, ElectricConductance.FromMicrosiemens(siemens.Microsiemens).Siemens, MicrosiemensTolerance);
            AssertEx.EqualTolerance(1, ElectricConductance.FromMillisiemens(siemens.Millisiemens).Siemens, MillisiemensTolerance);
            AssertEx.EqualTolerance(1, ElectricConductance.FromSiemens(siemens.Siemens).Siemens, SiemensTolerance);
        }
Ejemplo n.º 4
0
        public void CompareToIsImplemented()
        {
            ElectricConductance siemens = ElectricConductance.FromSiemens(1);

            Assert.Equal(0, siemens.CompareTo(siemens));
            Assert.True(siemens.CompareTo(ElectricConductance.Zero) > 0);
            Assert.True(ElectricConductance.Zero.CompareTo(siemens) < 0);
        }
Ejemplo n.º 5
0
        public void Equals_SameType_IsImplemented()
        {
            var a = ElectricConductance.FromSiemens(1);
            var b = ElectricConductance.FromSiemens(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
Ejemplo n.º 6
0
        public void SiemensToElectricConductanceUnits()
        {
            ElectricConductance siemens = ElectricConductance.FromSiemens(1);

            AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.Microsiemens, MicrosiemensTolerance);
            AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.Millisiemens, MillisiemensTolerance);
            AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.Siemens, SiemensTolerance);
        }
        public void FromSiemens_WithInfinityValue_CreateQuantityAndAffectInfinityValue()
        {
            var positiveInfinityQuantity = ElectricConductance.FromSiemens(double.PositiveInfinity);
            var negativeInfinityQuantity = ElectricConductance.FromSiemens(double.NegativeInfinity);

            Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value));
            Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value));
        }
Ejemplo n.º 8
0
        public void As()
        {
            var siemens = ElectricConductance.FromSiemens(1);

            AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Microsiemens), MicrosiemensTolerance);
            AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Millisiemens), MillisiemensTolerance);
            AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Siemens), SiemensTolerance);
        }
Ejemplo n.º 9
0
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = ElectricConductance.FromSiemens(1);
            object b = ElectricConductance.FromSiemens(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
        public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
        {
            var siemens = ElectricConductance.FromSiemens(1);

            Assert.Throws <ArgumentException>(() => siemens.ToUnit(UnitSystem.SI));
            Assert.Throws <ArgumentException>(() => siemens.ToUnit(UnitSystem.CGS));
            Assert.Throws <ArgumentException>(() => siemens.ToUnit(UnitSystem.BI));
            Assert.Throws <ArgumentException>(() => siemens.ToUnit(UnitSystem.EE));
            Assert.Throws <ArgumentException>(() => siemens.ToUnit(UnitSystem.USC));
            Assert.Throws <ArgumentException>(() => siemens.ToUnit(UnitSystem.FPS));
            Assert.Throws <ArgumentException>(() => siemens.ToUnit(UnitSystem.Astronomical));
        }
Ejemplo n.º 11
0
        public void ArithmeticOperators()
        {
            ElectricConductance v = ElectricConductance.FromSiemens(1);

            AssertEx.EqualTolerance(-1, -v.Siemens, SiemensTolerance);
            AssertEx.EqualTolerance(2, (ElectricConductance.FromSiemens(3) - v).Siemens, SiemensTolerance);
            AssertEx.EqualTolerance(2, (v + v).Siemens, SiemensTolerance);
            AssertEx.EqualTolerance(10, (v * 10).Siemens, SiemensTolerance);
            AssertEx.EqualTolerance(10, (10 * v).Siemens, SiemensTolerance);
            AssertEx.EqualTolerance(2, (ElectricConductance.FromSiemens(10) / 5).Siemens, SiemensTolerance);
            AssertEx.EqualTolerance(2, ElectricConductance.FromSiemens(10) / ElectricConductance.FromSiemens(5), SiemensTolerance);
        }
Ejemplo n.º 12
0
        public void EqualityOperators()
        {
            ElectricConductance a = ElectricConductance.FromSiemens(1);
            ElectricConductance b = ElectricConductance.FromSiemens(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.º 13
0
        public void ComparisonOperators()
        {
            ElectricConductance oneSiemens = ElectricConductance.FromSiemens(1);
            ElectricConductance twoSiemens = ElectricConductance.FromSiemens(2);

            Assert.True(oneSiemens < twoSiemens);
            Assert.True(oneSiemens <= twoSiemens);
            Assert.True(twoSiemens > oneSiemens);
            Assert.True(twoSiemens >= oneSiemens);

            Assert.False(oneSiemens > twoSiemens);
            Assert.False(oneSiemens >= twoSiemens);
            Assert.False(twoSiemens < oneSiemens);
            Assert.False(twoSiemens <= oneSiemens);
        }
Ejemplo n.º 14
0
        public void ToUnit()
        {
            var siemens = ElectricConductance.FromSiemens(1);

            var microsiemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Microsiemens);

            AssertEx.EqualTolerance(MicrosiemensInOneSiemens, (double)microsiemensQuantity.Value, MicrosiemensTolerance);
            Assert.Equal(ElectricConductanceUnit.Microsiemens, microsiemensQuantity.Unit);

            var millisiemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Millisiemens);

            AssertEx.EqualTolerance(MillisiemensInOneSiemens, (double)millisiemensQuantity.Value, MillisiemensTolerance);
            Assert.Equal(ElectricConductanceUnit.Millisiemens, millisiemensQuantity.Unit);

            var siemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Siemens);

            AssertEx.EqualTolerance(SiemensInOneSiemens, (double)siemensQuantity.Value, SiemensTolerance);
            Assert.Equal(ElectricConductanceUnit.Siemens, siemensQuantity.Unit);
        }
Ejemplo n.º 15
0
        public void EqualityOperators()
        {
            var a = ElectricConductance.FromSiemens(1);
            var b = ElectricConductance.FromSiemens(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.º 16
0
        public void EqualsReturnsFalseOnNull()
        {
            ElectricConductance siemens = ElectricConductance.FromSiemens(1);

            Assert.False(siemens.Equals(null));
        }
Ejemplo n.º 17
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            ElectricConductance siemens = ElectricConductance.FromSiemens(1);

            Assert.False(siemens.Equals(new object()));
        }
Ejemplo n.º 18
0
        public void Convert_ToInt32_EqualsValueAsSameType()
        {
            var quantity = ElectricConductance.FromSiemens(1.0);

            Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity));
        }
Ejemplo n.º 19
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = ElectricConductance.FromSiemens(1.0);

            Assert.Equal(QuantityType.ElectricConductance, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Ejemplo n.º 20
0
        public void CompareToThrowsOnNull()
        {
            ElectricConductance siemens = ElectricConductance.FromSiemens(1);

            Assert.Throws <ArgumentNullException>(() => siemens.CompareTo(null));
        }
Ejemplo n.º 21
0
        public void CompareToThrowsOnTypeMismatch()
        {
            ElectricConductance siemens = ElectricConductance.FromSiemens(1);

            Assert.Throws <ArgumentException>(() => siemens.CompareTo(new object()));
        }
Ejemplo n.º 22
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = ElectricConductance.FromSiemens(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Ejemplo n.º 23
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = ElectricConductance.FromSiemens(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricConductanceUnit)));
        }
Ejemplo n.º 24
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = ElectricConductance.FromSiemens(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Ejemplo n.º 25
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(decimal value)
        {
            var quantity = ElectricConductance.FromSiemens(value);

            Assert.Equal(ElectricConductance.FromSiemens(-value), -quantity);
        }
Ejemplo n.º 26
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = ElectricConductance.FromSiemens(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Ejemplo n.º 27
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = ElectricConductance.FromSiemens(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Ejemplo n.º 28
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = ElectricConductance.FromSiemens(1.0);

            Assert.Equal(ElectricConductance.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Ejemplo n.º 29
0
        public void GetHashCode_Equals()
        {
            var quantity = ElectricConductance.FromSiemens(1.0);

            Assert.Equal(new { ElectricConductance.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Ejemplo n.º 30
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = ElectricConductance.FromSiemens(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(ElectricConductance)));
        }