public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            Assert.True(v.Equals(SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1), GramsPerKiloNewtonSecondTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(SpecificFuelConsumption.Zero, GramsPerKiloNewtonSecondTolerance, ComparisonType.Relative));
        }
        public void CompareToIsImplemented()
        {
            SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

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

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
        public void ConversionRoundTrip()
        {
            SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            AssertEx.EqualTolerance(1, SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(gramperkilonewtonsecond.GramsPerKiloNewtonSecond).GramsPerKiloNewtonSecond, GramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(1, SpecificFuelConsumption.FromKilogramsPerKilogramForceHour(gramperkilonewtonsecond.KilogramsPerKilogramForceHour).GramsPerKiloNewtonSecond, KilogramsPerKilogramForceHourTolerance);
            AssertEx.EqualTolerance(1, SpecificFuelConsumption.FromKilogramsPerKiloNewtonSecond(gramperkilonewtonsecond.KilogramsPerKiloNewtonSecond).GramsPerKiloNewtonSecond, KilogramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(1, SpecificFuelConsumption.FromPoundsMassPerPoundForceHour(gramperkilonewtonsecond.PoundsMassPerPoundForceHour).GramsPerKiloNewtonSecond, PoundsMassPerPoundForceHourTolerance);
        }
        public void GramPerKiloNewtonSecondToSpecificFuelConsumptionUnits()
        {
            SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            AssertEx.EqualTolerance(GramsPerKiloNewtonSecondInOneGramPerKiloNewtonSecond, gramperkilonewtonsecond.GramsPerKiloNewtonSecond, GramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(KilogramsPerKilogramForceHourInOneGramPerKiloNewtonSecond, gramperkilonewtonsecond.KilogramsPerKilogramForceHour, KilogramsPerKilogramForceHourTolerance);
            AssertEx.EqualTolerance(KilogramsPerKiloNewtonSecondInOneGramPerKiloNewtonSecond, gramperkilonewtonsecond.KilogramsPerKiloNewtonSecond, KilogramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(PoundsMassPerPoundForceHourInOneGramPerKiloNewtonSecond, gramperkilonewtonsecond.PoundsMassPerPoundForceHour, PoundsMassPerPoundForceHourTolerance);
        }
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);
            object b = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
        public void As()
        {
            var gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            AssertEx.EqualTolerance(GramsPerKiloNewtonSecondInOneGramPerKiloNewtonSecond, gramperkilonewtonsecond.As(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond), GramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(KilogramsPerKilogramForceHourInOneGramPerKiloNewtonSecond, gramperkilonewtonsecond.As(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour), KilogramsPerKilogramForceHourTolerance);
            AssertEx.EqualTolerance(KilogramsPerKiloNewtonSecondInOneGramPerKiloNewtonSecond, gramperkilonewtonsecond.As(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond), KilogramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(PoundsMassPerPoundForceHourInOneGramPerKiloNewtonSecond, gramperkilonewtonsecond.As(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour), PoundsMassPerPoundForceHourTolerance);
        }
        public void ArithmeticOperators()
        {
            SpecificFuelConsumption v = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            AssertEx.EqualTolerance(-1, -v.GramsPerKiloNewtonSecond, GramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(2, (SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(3) - v).GramsPerKiloNewtonSecond, GramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(2, (v + v).GramsPerKiloNewtonSecond, GramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(10, (v * 10).GramsPerKiloNewtonSecond, GramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(10, (10 * v).GramsPerKiloNewtonSecond, GramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(2, (SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(10) / 5).GramsPerKiloNewtonSecond, GramsPerKiloNewtonSecondTolerance);
            AssertEx.EqualTolerance(2, SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(10) / SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(5), GramsPerKiloNewtonSecondTolerance);
        }
        public void ComparisonOperators()
        {
            SpecificFuelConsumption oneGramPerKiloNewtonSecond  = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);
            SpecificFuelConsumption twoGramsPerKiloNewtonSecond = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(2);

            Assert.True(oneGramPerKiloNewtonSecond < twoGramsPerKiloNewtonSecond);
            Assert.True(oneGramPerKiloNewtonSecond <= twoGramsPerKiloNewtonSecond);
            Assert.True(twoGramsPerKiloNewtonSecond > oneGramPerKiloNewtonSecond);
            Assert.True(twoGramsPerKiloNewtonSecond >= oneGramPerKiloNewtonSecond);

            Assert.False(oneGramPerKiloNewtonSecond > twoGramsPerKiloNewtonSecond);
            Assert.False(oneGramPerKiloNewtonSecond >= twoGramsPerKiloNewtonSecond);
            Assert.False(twoGramsPerKiloNewtonSecond < oneGramPerKiloNewtonSecond);
            Assert.False(twoGramsPerKiloNewtonSecond <= oneGramPerKiloNewtonSecond);
        }
        public void EqualityOperators()
        {
            var a = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);
            var b = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(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
        }
        public void ToUnit()
        {
            var gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            var gramperkilonewtonsecondQuantity = gramperkilonewtonsecond.ToUnit(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond);

            AssertEx.EqualTolerance(GramsPerKiloNewtonSecondInOneGramPerKiloNewtonSecond, (double)gramperkilonewtonsecondQuantity.Value, GramsPerKiloNewtonSecondTolerance);
            Assert.Equal(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, gramperkilonewtonsecondQuantity.Unit);

            var kilogramperkilogramforcehourQuantity = gramperkilonewtonsecond.ToUnit(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour);

            AssertEx.EqualTolerance(KilogramsPerKilogramForceHourInOneGramPerKiloNewtonSecond, (double)kilogramperkilogramforcehourQuantity.Value, KilogramsPerKilogramForceHourTolerance);
            Assert.Equal(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, kilogramperkilogramforcehourQuantity.Unit);

            var kilogramperkilonewtonsecondQuantity = gramperkilonewtonsecond.ToUnit(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond);

            AssertEx.EqualTolerance(KilogramsPerKiloNewtonSecondInOneGramPerKiloNewtonSecond, (double)kilogramperkilonewtonsecondQuantity.Value, KilogramsPerKiloNewtonSecondTolerance);
            Assert.Equal(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, kilogramperkilonewtonsecondQuantity.Unit);

            var poundmassperpoundforcehourQuantity = gramperkilonewtonsecond.ToUnit(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour);

            AssertEx.EqualTolerance(PoundsMassPerPoundForceHourInOneGramPerKiloNewtonSecond, (double)poundmassperpoundforcehourQuantity.Value, PoundsMassPerPoundForceHourTolerance);
            Assert.Equal(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, poundmassperpoundforcehourQuantity.Unit);
        }
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificFuelConsumptionUnit)));
        }
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
        public void Convert_ToString_EqualsToString()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
        public void CompareToThrowsOnNull()
        {
            SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            Assert.Throws <ArgumentNullException>(() => gramperkilonewtonsecond.CompareTo(null));
        }
        public void EqualsReturnsFalseOnNull()
        {
            SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            Assert.False(gramperkilonewtonsecond.Equals(null));
        }
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value);

            Assert.Equal(SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(-value), -quantity);
        }
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
        public void ToBaseUnit_ReturnsQuantityWithBaseUnit()
        {
            var quantityInBaseUnit = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1).ToBaseUnit();

            Assert.Equal(SpecificFuelConsumption.BaseUnit, quantityInBaseUnit.Unit);
        }
        public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Equal(SpecificFuelConsumption.Info, Convert.ChangeType(quantity, typeof(QuantityInfo)));
        }
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Equal(SpecificFuelConsumption.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
        public void CompareToThrowsOnTypeMismatch()
        {
            SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            Assert.Throws <ArgumentException>(() => gramperkilonewtonsecond.CompareTo(new object()));
        }
        public void GetHashCode_Equals()
        {
            var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0);

            Assert.Equal(new { SpecificFuelConsumption.Info.Name, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1), -1, ComparisonType.Relative));
        }
 public void NumberToGramsPerKiloNewtonSecondTest() =>
 Assert.Equal(SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(2), 2.GramsPerKiloNewtonSecond());
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            SpecificFuelConsumption gramperkilonewtonsecond = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1);

            Assert.False(gramperkilonewtonsecond.Equals(new object()));
        }