Exemplo n.º 1
0
        public void ToUnit()
        {
            var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1);

            var cubicmeterpermeterQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.CubicMeterPerMeter);

            AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, (double)cubicmeterpermeterQuantity.Value, CubicMetersPerMeterTolerance);
            Assert.Equal(VolumePerLengthUnit.CubicMeterPerMeter, cubicmeterpermeterQuantity.Unit);

            var cubicyardperfootQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.CubicYardPerFoot);

            AssertEx.EqualTolerance(CubicYardsPerFootInOneCubicMeterPerMeter, (double)cubicyardperfootQuantity.Value, CubicYardsPerFootTolerance);
            Assert.Equal(VolumePerLengthUnit.CubicYardPerFoot, cubicyardperfootQuantity.Unit);

            var cubicyardperussurveyfootQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.CubicYardPerUsSurveyFoot);

            AssertEx.EqualTolerance(CubicYardsPerUsSurveyFootInOneCubicMeterPerMeter, (double)cubicyardperussurveyfootQuantity.Value, CubicYardsPerUsSurveyFootTolerance);
            Assert.Equal(VolumePerLengthUnit.CubicYardPerUsSurveyFoot, cubicyardperussurveyfootQuantity.Unit);

            var literpermeterQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.LiterPerMeter);

            AssertEx.EqualTolerance(LitersPerMeterInOneCubicMeterPerMeter, (double)literpermeterQuantity.Value, LitersPerMeterTolerance);
            Assert.Equal(VolumePerLengthUnit.LiterPerMeter, literpermeterQuantity.Unit);

            var oilbarrelperfootQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.OilBarrelPerFoot);

            AssertEx.EqualTolerance(OilBarrelsPerFootInOneCubicMeterPerMeter, (double)oilbarrelperfootQuantity.Value, OilBarrelsPerFootTolerance);
            Assert.Equal(VolumePerLengthUnit.OilBarrelPerFoot, oilbarrelperfootQuantity.Unit);
        }
Exemplo n.º 2
0
        public void EqualsRelativeToleranceIsImplemented()
        {
            var v = VolumePerLength.FromCubicMetersPerMeter(1);

            Assert.True(v.Equals(VolumePerLength.FromCubicMetersPerMeter(1), CubicMetersPerMeterTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(VolumePerLength.Zero, CubicMetersPerMeterTolerance, ComparisonType.Relative));
        }
Exemplo n.º 3
0
        public void CompareToIsImplemented()
        {
            VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1);

            Assert.Equal(0, cubicmeterpermeter.CompareTo(cubicmeterpermeter));
            Assert.True(cubicmeterpermeter.CompareTo(VolumePerLength.Zero) > 0);
            Assert.True(VolumePerLength.Zero.CompareTo(cubicmeterpermeter) < 0);
        }
        public void Equals_SameType_IsImplemented()
        {
            var a = VolumePerLength.FromCubicMetersPerMeter(1);
            var b = VolumePerLength.FromCubicMetersPerMeter(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
        public void FromCubicMetersPerMeter_WithInfinityValue_CreateQuantityAndAffectInfinityValue()
        {
            var positiveInfinityQuantity = VolumePerLength.FromCubicMetersPerMeter(double.PositiveInfinity);
            var negativeInfinityQuantity = VolumePerLength.FromCubicMetersPerMeter(double.NegativeInfinity);

            Assert.True(double.IsPositiveInfinity(positiveInfinityQuantity.Value));
            Assert.True(double.IsNegativeInfinity(negativeInfinityQuantity.Value));
        }
Exemplo n.º 6
0
        public void CubicMeterPerMeterToVolumePerLengthUnits()
        {
            VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1);

            AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.CubicMetersPerMeter, CubicMetersPerMeterTolerance);
            AssertEx.EqualTolerance(LitersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.LitersPerMeter, LitersPerMeterTolerance);
            AssertEx.EqualTolerance(OilBarrelsPerFootInOneCubicMeterPerMeter, cubicmeterpermeter.OilBarrelsPerFoot, OilBarrelsPerFootTolerance);
        }
Exemplo n.º 7
0
        public void ConversionRoundTrip()
        {
            VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1);

            AssertEx.EqualTolerance(1, VolumePerLength.FromCubicMetersPerMeter(cubicmeterpermeter.CubicMetersPerMeter).CubicMetersPerMeter, CubicMetersPerMeterTolerance);
            AssertEx.EqualTolerance(1, VolumePerLength.FromLitersPerMeter(cubicmeterpermeter.LitersPerMeter).CubicMetersPerMeter, LitersPerMeterTolerance);
            AssertEx.EqualTolerance(1, VolumePerLength.FromOilBarrelsPerFoot(cubicmeterpermeter.OilBarrelsPerFoot).CubicMetersPerMeter, OilBarrelsPerFootTolerance);
        }
Exemplo n.º 8
0
        public void As()
        {
            var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1);

            AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.CubicMeterPerMeter), CubicMetersPerMeterTolerance);
            AssertEx.EqualTolerance(LitersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.LiterPerMeter), LitersPerMeterTolerance);
            AssertEx.EqualTolerance(OilBarrelsPerFootInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.OilBarrelPerFoot), OilBarrelsPerFootTolerance);
        }
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = VolumePerLength.FromCubicMetersPerMeter(1);
            object b = VolumePerLength.FromCubicMetersPerMeter(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
Exemplo n.º 10
0
        public void To_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
        {
            var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1);

            Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.SI));
            Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.CGS));
            Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.BI));
            Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.EE));
            Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.USC));
            Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.FPS));
            Assert.Throws <ArgumentException>(() => cubicmeterpermeter.ToUnit(UnitSystem.Astronomical));
        }
Exemplo n.º 11
0
        public void ArithmeticOperators()
        {
            VolumePerLength v = VolumePerLength.FromCubicMetersPerMeter(1);

            AssertEx.EqualTolerance(-1, -v.CubicMetersPerMeter, CubicMetersPerMeterTolerance);
            AssertEx.EqualTolerance(2, (VolumePerLength.FromCubicMetersPerMeter(3) - v).CubicMetersPerMeter, CubicMetersPerMeterTolerance);
            AssertEx.EqualTolerance(2, (v + v).CubicMetersPerMeter, CubicMetersPerMeterTolerance);
            AssertEx.EqualTolerance(10, (v * 10).CubicMetersPerMeter, CubicMetersPerMeterTolerance);
            AssertEx.EqualTolerance(10, (10 * v).CubicMetersPerMeter, CubicMetersPerMeterTolerance);
            AssertEx.EqualTolerance(2, (VolumePerLength.FromCubicMetersPerMeter(10) / 5).CubicMetersPerMeter, CubicMetersPerMeterTolerance);
            AssertEx.EqualTolerance(2, VolumePerLength.FromCubicMetersPerMeter(10) / VolumePerLength.FromCubicMetersPerMeter(5), CubicMetersPerMeterTolerance);
        }
Exemplo n.º 12
0
        public void ComparisonOperators()
        {
            VolumePerLength oneCubicMeterPerMeter  = VolumePerLength.FromCubicMetersPerMeter(1);
            VolumePerLength twoCubicMetersPerMeter = VolumePerLength.FromCubicMetersPerMeter(2);

            Assert.True(oneCubicMeterPerMeter < twoCubicMetersPerMeter);
            Assert.True(oneCubicMeterPerMeter <= twoCubicMetersPerMeter);
            Assert.True(twoCubicMetersPerMeter > oneCubicMeterPerMeter);
            Assert.True(twoCubicMetersPerMeter >= oneCubicMeterPerMeter);

            Assert.False(oneCubicMeterPerMeter > twoCubicMetersPerMeter);
            Assert.False(oneCubicMeterPerMeter >= twoCubicMetersPerMeter);
            Assert.False(twoCubicMetersPerMeter < oneCubicMeterPerMeter);
            Assert.False(twoCubicMetersPerMeter <= oneCubicMeterPerMeter);
        }
Exemplo n.º 13
0
        public void EqualityOperators()
        {
            var a = VolumePerLength.FromCubicMetersPerMeter(1);
            var b = VolumePerLength.FromCubicMetersPerMeter(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.º 14
0
        public void CompareToThrowsOnNull()
        {
            VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1);

            Assert.Throws <ArgumentNullException>(() => cubicmeterpermeter.CompareTo(null));
        }
Exemplo n.º 15
0
        public void CompareToThrowsOnTypeMismatch()
        {
            VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1);

            Assert.Throws <ArgumentException>(() => cubicmeterpermeter.CompareTo(new object()));
        }
Exemplo n.º 16
0
        public void Convert_ToInt16_EqualsValueAsSameType()
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0);

            Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity));
        }
Exemplo n.º 17
0
 public void FromCubicMetersPerMeter_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => VolumePerLength.FromCubicMetersPerMeter(double.NaN));
 }
Exemplo n.º 18
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Exemplo n.º 19
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(value);

            Assert.Equal(VolumePerLength.FromCubicMetersPerMeter(-value), -quantity);
        }
Exemplo n.º 20
0
        public void GetHashCode_Equals()
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0);

            Assert.Equal(new { VolumePerLength.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Exemplo n.º 21
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Exemplo n.º 22
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Exemplo n.º 23
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1);

            Assert.False(cubicmeterpermeter.Equals(new object()));
        }
Exemplo n.º 24
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumePerLengthUnit)));
        }
Exemplo n.º 25
0
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(VolumePerLength)));
        }
Exemplo n.º 26
0
 public void FromCubicMetersPerMeter_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => VolumePerLength.FromCubicMetersPerMeter(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => VolumePerLength.FromCubicMetersPerMeter(double.NegativeInfinity));
 }
Exemplo n.º 27
0
        public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo()
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0);

            Assert.Equal(VolumePerLength.Info, Convert.ChangeType(quantity, typeof(QuantityInfo)));
        }
Exemplo n.º 28
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Exemplo n.º 29
0
        public void EqualsReturnsFalseOnNull()
        {
            VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1);

            Assert.False(cubicmeterpermeter.Equals(null));
        }
Exemplo n.º 30
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0);

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