コード例 #1
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
コード例 #2
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
コード例 #3
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
コード例 #4
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
コード例 #5
0
 public void FromKilogramsPerJoule_WithInfinityValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.PositiveInfinity));
     Assert.Throws <ArgumentException>(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NegativeInfinity));
 }
コード例 #6
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
コード例 #7
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1), -1, ComparisonType.Relative));
        }
コード例 #8
0
        public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(BrakeSpecificFuelConsumption.Info, Convert.ChangeType(quantity, typeof(QuantityInfo)));
        }
コード例 #9
0
        public void CompareToThrowsOnTypeMismatch()
        {
            BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.Throws <ArgumentException>(() => kilogramperjoule.CompareTo(new object()));
        }
コード例 #10
0
        public void CompareToThrowsOnNull()
        {
            BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.Throws <ArgumentNullException>(() => kilogramperjoule.CompareTo(null));
        }
コード例 #11
0
        public void ArithmeticOperators()
        {
            BrakeSpecificFuelConsumption v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            AssertEx.EqualTolerance(-1, -v.KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(3) - v).KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(2, (v + v).KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(10, (v * 10).KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(10, (10 * v).KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10) / 5).KilogramsPerJoule, KilogramsPerJouleTolerance);
            AssertEx.EqualTolerance(2, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10) / BrakeSpecificFuelConsumption.FromKilogramsPerJoule(5), KilogramsPerJouleTolerance);
        }
コード例 #12
0
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1).ToBaseUnit();

            Assert.Equal(BrakeSpecificFuelConsumption.BaseUnit, quantityInBaseUnit.Unit);
        }
コード例 #13
0
 public void FromKilogramsPerJoule_WithNanValue_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NaN));
 }
コード例 #14
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
コード例 #15
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.False(kilogramperjoule.Equals(new object()));
        }
コード例 #16
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(BrakeSpecificFuelConsumptionUnit)));
        }
コード例 #17
0
        public void EqualsReturnsFalseOnNull()
        {
            BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1);

            Assert.False(kilogramperjoule.Equals(null));
        }
コード例 #18
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0);

            Assert.Equal(BrakeSpecificFuelConsumption.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
コード例 #19
0
ファイル: PowerTests.cs プロジェクト: zykovaa-eplan/UnitsNet
        public void PowerTimesBrakeSpecificFuelConsumptionEqualsMassFlow()
        {
            MassFlow massFlow = Power.FromKilowatts(20.0 / 24.0 * 1e6 / 180.0) * BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0);

            AssertEx.EqualTolerance(massFlow.TonnesPerDay, 20.0, 1e-11);
        }