コード例 #1
0
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            Assert.True(v.Equals(ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1), SquareMeterCelciusDegreePerKilowattsTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(ThermalInsulance.Zero, SquareMeterCelciusDegreePerKilowattsTolerance, ComparisonType.Relative));
        }
コード例 #2
0
        public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
        {
            var quantity00 = ThermalInsulance.From(1, ThermalInsulanceUnit.SquareMeterCelciusDegreePerKilowatt);

            AssertEx.EqualTolerance(1, quantity00.SquareMeterCelciusDegreePerKilowatts, SquareMeterCelciusDegreePerKilowattsTolerance);
            Assert.Equal(ThermalInsulanceUnit.SquareMeterCelciusDegreePerKilowatt, quantity00.Unit);
        }
コード例 #3
0
        public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit()
        {
            var quantity = new ThermalInsulance();

            Assert.Equal(0, quantity.Value);
            Assert.Equal(ThermalInsulanceUnit.SquareMeterCelciusDegreePerKilowatt, quantity.Unit);
        }
コード例 #4
0
        public void Equals_SameType_IsImplemented()
        {
            var a = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);
            var b = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
コード例 #5
0
        public void CompareToIsImplemented()
        {
            ThermalInsulance squaremetercelciusdegreeperkilowatt = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            Assert.Equal(0, squaremetercelciusdegreeperkilowatt.CompareTo(squaremetercelciusdegreeperkilowatt));
            Assert.True(squaremetercelciusdegreeperkilowatt.CompareTo(ThermalInsulance.Zero) > 0);
            Assert.True(ThermalInsulance.Zero.CompareTo(squaremetercelciusdegreeperkilowatt) < 0);
        }
コード例 #6
0
        public void ToUnit()
        {
            var squaremetercelciusdegreeperkilowatt = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            var squaremetercelciusdegreeperkilowattQuantity = squaremetercelciusdegreeperkilowatt.ToUnit(ThermalInsulanceUnit.SquareMeterCelciusDegreePerKilowatt);

            AssertEx.EqualTolerance(SquareMeterCelciusDegreePerKilowattsInOneSquareMeterCelciusDegreePerKilowatt, (double)squaremetercelciusdegreeperkilowattQuantity.Value, SquareMeterCelciusDegreePerKilowattsTolerance);
            Assert.Equal(ThermalInsulanceUnit.SquareMeterCelciusDegreePerKilowatt, squaremetercelciusdegreeperkilowattQuantity.Unit);
        }
コード例 #7
0
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);
            object b = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
コード例 #8
0
        public void ArithmeticOperators()
        {
            ThermalInsulance v = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            AssertEx.EqualTolerance(-1, -v.SquareMeterCelciusDegreePerKilowatts, SquareMeterCelciusDegreePerKilowattsTolerance);
            AssertEx.EqualTolerance(2, (ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(3) - v).SquareMeterCelciusDegreePerKilowatts, SquareMeterCelciusDegreePerKilowattsTolerance);
            AssertEx.EqualTolerance(2, (v + v).SquareMeterCelciusDegreePerKilowatts, SquareMeterCelciusDegreePerKilowattsTolerance);
            AssertEx.EqualTolerance(10, (v * 10).SquareMeterCelciusDegreePerKilowatts, SquareMeterCelciusDegreePerKilowattsTolerance);
            AssertEx.EqualTolerance(10, (10 * v).SquareMeterCelciusDegreePerKilowatts, SquareMeterCelciusDegreePerKilowattsTolerance);
            AssertEx.EqualTolerance(2, (ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(10) / 5).SquareMeterCelciusDegreePerKilowatts, SquareMeterCelciusDegreePerKilowattsTolerance);
            AssertEx.EqualTolerance(2, ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(10) / ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(5), SquareMeterCelciusDegreePerKilowattsTolerance);
        }
コード例 #9
0
        public void ComparisonOperators()
        {
            ThermalInsulance oneSquareMeterCelciusDegreePerKilowatt  = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);
            ThermalInsulance twoSquareMeterCelciusDegreePerKilowatts = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(2);

            Assert.True(oneSquareMeterCelciusDegreePerKilowatt < twoSquareMeterCelciusDegreePerKilowatts);
            Assert.True(oneSquareMeterCelciusDegreePerKilowatt <= twoSquareMeterCelciusDegreePerKilowatts);
            Assert.True(twoSquareMeterCelciusDegreePerKilowatts > oneSquareMeterCelciusDegreePerKilowatt);
            Assert.True(twoSquareMeterCelciusDegreePerKilowatts >= oneSquareMeterCelciusDegreePerKilowatt);

            Assert.False(oneSquareMeterCelciusDegreePerKilowatt > twoSquareMeterCelciusDegreePerKilowatts);
            Assert.False(oneSquareMeterCelciusDegreePerKilowatt >= twoSquareMeterCelciusDegreePerKilowatts);
            Assert.False(twoSquareMeterCelciusDegreePerKilowatts < oneSquareMeterCelciusDegreePerKilowatt);
            Assert.False(twoSquareMeterCelciusDegreePerKilowatts <= oneSquareMeterCelciusDegreePerKilowatt);
        }
コード例 #10
0
        public void EqualityOperators()
        {
            var a = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);
            var b = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(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
        }
コード例 #11
0
        public void ThermalInsulance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity()
        {
            var quantity = new ThermalInsulance(1, ThermalInsulanceUnit.SquareMeterCelciusDegreePerKilowatt);

            QuantityInfo <ThermalInsulanceUnit> quantityInfo = quantity.QuantityInfo;

            Assert.Equal(ThermalInsulance.Zero, quantityInfo.Zero);
            Assert.Equal("ThermalInsulance", quantityInfo.Name);
            Assert.Equal(QuantityType.ThermalInsulance, quantityInfo.QuantityType);

            var units     = EnumUtils.GetEnumValues <ThermalInsulanceUnit>().Except(new[] { ThermalInsulanceUnit.Undefined }).ToArray();
            var unitNames = units.Select(x => x.ToString());

            // Obsolete members
#pragma warning disable 618
            Assert.Equal(units, quantityInfo.Units);
            Assert.Equal(unitNames, quantityInfo.UnitNames);
#pragma warning restore 618
        }
コード例 #12
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ThermalInsulanceUnit)));
        }
コード例 #13
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
コード例 #14
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
コード例 #15
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
コード例 #16
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
コード例 #17
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
コード例 #18
0
        public void As()
        {
            var squaremetercelciusdegreeperkilowatt = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            AssertEx.EqualTolerance(SquareMeterCelciusDegreePerKilowattsInOneSquareMeterCelciusDegreePerKilowatt, squaremetercelciusdegreeperkilowatt.As(ThermalInsulanceUnit.SquareMeterCelciusDegreePerKilowatt), SquareMeterCelciusDegreePerKilowattsTolerance);
        }
コード例 #19
0
        public void ConversionRoundTrip()
        {
            ThermalInsulance squaremetercelciusdegreeperkilowatt = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            AssertEx.EqualTolerance(1, ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(squaremetercelciusdegreeperkilowatt.SquareMeterCelciusDegreePerKilowatts).SquareMeterCelciusDegreePerKilowatts, SquareMeterCelciusDegreePerKilowattsTolerance);
        }
コード例 #20
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1.0);

            Assert.Equal(QuantityType.ThermalInsulance, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
コード例 #21
0
        public void CompareToThrowsOnNull()
        {
            ThermalInsulance squaremetercelciusdegreeperkilowatt = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            Assert.Throws <ArgumentNullException>(() => squaremetercelciusdegreeperkilowatt.CompareTo(null));
        }
コード例 #22
0
        public void CompareToThrowsOnTypeMismatch()
        {
            ThermalInsulance squaremetercelciusdegreeperkilowatt = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            Assert.Throws <ArgumentException>(() => squaremetercelciusdegreeperkilowatt.CompareTo(new object()));
        }
コード例 #23
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1.0);

            Assert.Equal(ThermalInsulance.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
コード例 #24
0
        public void GetHashCode_Equals()
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1.0);

            Assert.Equal(new { ThermalInsulance.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
コード例 #25
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
コード例 #26
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1), -1, ComparisonType.Relative));
        }
コード例 #27
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(value);

            Assert.Equal(ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(-value), -quantity);
        }
コード例 #28
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            ThermalInsulance squaremetercelciusdegreeperkilowatt = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            Assert.False(squaremetercelciusdegreeperkilowatt.Equals(new object()));
        }
コード例 #29
0
 public void NumberToSquareMeterCelciusDegreePerKilowattsTest() =>
 Assert.Equal(ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(2), 2.SquareMeterCelciusDegreePerKilowatts());
コード例 #30
0
        public void EqualsReturnsFalseOnNull()
        {
            ThermalInsulance squaremetercelciusdegreeperkilowatt = ThermalInsulance.FromSquareMeterCelciusDegreePerKilowatts(1);

            Assert.False(squaremetercelciusdegreeperkilowatt.Equals(null));
        }