From ac3e270de14df7c14bc6991cc3333bf5b61dfdce Mon Sep 17 00:00:00 2001 From: Daniel Sirz Date: Thu, 2 Jun 2016 18:07:36 +0200 Subject: [PATCH] Added MassFlowUnit.KilogramPerHour --- UnitsNet.Tests/CustomCode/MassFlowTests.cs | 1 + .../GeneratedCode/MassFlowTestsBase.g.cs | 6 +++ .../GeneratedCode/Enums/MassFlowUnit.g.cs | 1 + .../GeneratedCode/UnitClasses/MassFlow.g.cs | 37 +++++++++++++++++++ .../GeneratedCode/UnitSystem.Default.g.cs | 6 +++ .../Scripts/UnitDefinitions/MassFlow.json | 18 ++++++++- 6 files changed, 68 insertions(+), 1 deletion(-) diff --git a/UnitsNet.Tests/CustomCode/MassFlowTests.cs b/UnitsNet.Tests/CustomCode/MassFlowTests.cs index ae20dcbf07..194c9f6391 100644 --- a/UnitsNet.Tests/CustomCode/MassFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFlowTests.cs @@ -31,6 +31,7 @@ public class MassFlowTests : MassFlowTestsBase protected override double DecagramsPerSecondInOneGramPerSecond => 1E-1; protected override double HectogramsPerSecondInOneGramPerSecond => 1E-2; + protected override double KilogramsPerHourInOneGramPerSecond => 3.6; protected override double KilogramsPerSecondInOneGramPerSecond => 1E-3; diff --git a/UnitsNet.Tests/GeneratedCode/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MassFlowTestsBase.g.cs index 8b7eb221bc..5b0d5cc58d 100644 --- a/UnitsNet.Tests/GeneratedCode/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/MassFlowTestsBase.g.cs @@ -41,6 +41,7 @@ public abstract partial class MassFlowTestsBase protected abstract double DecigramsPerSecondInOneGramPerSecond { get; } protected abstract double GramsPerSecondInOneGramPerSecond { get; } protected abstract double HectogramsPerSecondInOneGramPerSecond { get; } + protected abstract double KilogramsPerHourInOneGramPerSecond { get; } protected abstract double KilogramsPerSecondInOneGramPerSecond { get; } protected abstract double MicrogramsPerSecondInOneGramPerSecond { get; } protected abstract double MilligramsPerSecondInOneGramPerSecond { get; } @@ -53,6 +54,7 @@ public abstract partial class MassFlowTestsBase protected virtual double DecigramsPerSecondTolerance { get { return 1e-5; } } protected virtual double GramsPerSecondTolerance { get { return 1e-5; } } protected virtual double HectogramsPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerHourTolerance { get { return 1e-5; } } protected virtual double KilogramsPerSecondTolerance { get { return 1e-5; } } protected virtual double MicrogramsPerSecondTolerance { get { return 1e-5; } } protected virtual double MilligramsPerSecondTolerance { get { return 1e-5; } } @@ -69,6 +71,7 @@ public void GramPerSecondToMassFlowUnits() Assert.AreEqual(DecigramsPerSecondInOneGramPerSecond, grampersecond.DecigramsPerSecond, DecigramsPerSecondTolerance); Assert.AreEqual(GramsPerSecondInOneGramPerSecond, grampersecond.GramsPerSecond, GramsPerSecondTolerance); Assert.AreEqual(HectogramsPerSecondInOneGramPerSecond, grampersecond.HectogramsPerSecond, HectogramsPerSecondTolerance); + Assert.AreEqual(KilogramsPerHourInOneGramPerSecond, grampersecond.KilogramsPerHour, KilogramsPerHourTolerance); Assert.AreEqual(KilogramsPerSecondInOneGramPerSecond, grampersecond.KilogramsPerSecond, KilogramsPerSecondTolerance); Assert.AreEqual(MicrogramsPerSecondInOneGramPerSecond, grampersecond.MicrogramsPerSecond, MicrogramsPerSecondTolerance); Assert.AreEqual(MilligramsPerSecondInOneGramPerSecond, grampersecond.MilligramsPerSecond, MilligramsPerSecondTolerance); @@ -84,6 +87,7 @@ public void FromValueAndUnit() Assert.AreEqual(1, MassFlow.From(1, MassFlowUnit.DecigramPerSecond).DecigramsPerSecond, DecigramsPerSecondTolerance); Assert.AreEqual(1, MassFlow.From(1, MassFlowUnit.GramPerSecond).GramsPerSecond, GramsPerSecondTolerance); Assert.AreEqual(1, MassFlow.From(1, MassFlowUnit.HectogramPerSecond).HectogramsPerSecond, HectogramsPerSecondTolerance); + Assert.AreEqual(1, MassFlow.From(1, MassFlowUnit.KilogramPerHour).KilogramsPerHour, KilogramsPerHourTolerance); Assert.AreEqual(1, MassFlow.From(1, MassFlowUnit.KilogramPerSecond).KilogramsPerSecond, KilogramsPerSecondTolerance); Assert.AreEqual(1, MassFlow.From(1, MassFlowUnit.MicrogramPerSecond).MicrogramsPerSecond, MicrogramsPerSecondTolerance); Assert.AreEqual(1, MassFlow.From(1, MassFlowUnit.MilligramPerSecond).MilligramsPerSecond, MilligramsPerSecondTolerance); @@ -100,6 +104,7 @@ public void As() Assert.AreEqual(DecigramsPerSecondInOneGramPerSecond, grampersecond.As(MassFlowUnit.DecigramPerSecond), DecigramsPerSecondTolerance); Assert.AreEqual(GramsPerSecondInOneGramPerSecond, grampersecond.As(MassFlowUnit.GramPerSecond), GramsPerSecondTolerance); Assert.AreEqual(HectogramsPerSecondInOneGramPerSecond, grampersecond.As(MassFlowUnit.HectogramPerSecond), HectogramsPerSecondTolerance); + Assert.AreEqual(KilogramsPerHourInOneGramPerSecond, grampersecond.As(MassFlowUnit.KilogramPerHour), KilogramsPerHourTolerance); Assert.AreEqual(KilogramsPerSecondInOneGramPerSecond, grampersecond.As(MassFlowUnit.KilogramPerSecond), KilogramsPerSecondTolerance); Assert.AreEqual(MicrogramsPerSecondInOneGramPerSecond, grampersecond.As(MassFlowUnit.MicrogramPerSecond), MicrogramsPerSecondTolerance); Assert.AreEqual(MilligramsPerSecondInOneGramPerSecond, grampersecond.As(MassFlowUnit.MilligramPerSecond), MilligramsPerSecondTolerance); @@ -116,6 +121,7 @@ public void ConversionRoundTrip() Assert.AreEqual(1, MassFlow.FromDecigramsPerSecond(grampersecond.DecigramsPerSecond).GramsPerSecond, DecigramsPerSecondTolerance); Assert.AreEqual(1, MassFlow.FromGramsPerSecond(grampersecond.GramsPerSecond).GramsPerSecond, GramsPerSecondTolerance); Assert.AreEqual(1, MassFlow.FromHectogramsPerSecond(grampersecond.HectogramsPerSecond).GramsPerSecond, HectogramsPerSecondTolerance); + Assert.AreEqual(1, MassFlow.FromKilogramsPerHour(grampersecond.KilogramsPerHour).GramsPerSecond, KilogramsPerHourTolerance); Assert.AreEqual(1, MassFlow.FromKilogramsPerSecond(grampersecond.KilogramsPerSecond).GramsPerSecond, KilogramsPerSecondTolerance); Assert.AreEqual(1, MassFlow.FromMicrogramsPerSecond(grampersecond.MicrogramsPerSecond).GramsPerSecond, MicrogramsPerSecondTolerance); Assert.AreEqual(1, MassFlow.FromMilligramsPerSecond(grampersecond.MilligramsPerSecond).GramsPerSecond, MilligramsPerSecondTolerance); diff --git a/UnitsNet/GeneratedCode/Enums/MassFlowUnit.g.cs b/UnitsNet/GeneratedCode/Enums/MassFlowUnit.g.cs index 910c286da5..cd06fa36b5 100644 --- a/UnitsNet/GeneratedCode/Enums/MassFlowUnit.g.cs +++ b/UnitsNet/GeneratedCode/Enums/MassFlowUnit.g.cs @@ -30,6 +30,7 @@ public enum MassFlowUnit DecigramPerSecond, GramPerSecond, HectogramPerSecond, + KilogramPerHour, KilogramPerSecond, MicrogramPerSecond, MilligramPerSecond, diff --git a/UnitsNet/GeneratedCode/UnitClasses/MassFlow.g.cs b/UnitsNet/GeneratedCode/UnitClasses/MassFlow.g.cs index 692b9f8d6c..c29ca1b6c5 100644 --- a/UnitsNet/GeneratedCode/UnitClasses/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/UnitClasses/MassFlow.g.cs @@ -133,6 +133,14 @@ public double HectogramsPerSecond get { return (_gramsPerSecond) / 1e2d; } } + /// + /// Get MassFlow in KilogramsPerHour. + /// + public double KilogramsPerHour + { + get { return _gramsPerSecond/0.277778; } + } + /// /// Get MassFlow in KilogramsPerSecond. /// @@ -222,6 +230,14 @@ public static MassFlow FromHectogramsPerSecond(double hectogramspersecond) return new MassFlow((hectogramspersecond) * 1e2d); } + /// + /// Get MassFlow from KilogramsPerHour. + /// + public static MassFlow FromKilogramsPerHour(double kilogramsperhour) + { + return new MassFlow(kilogramsperhour*0.277778); + } + /// /// Get MassFlow from KilogramsPerSecond. /// @@ -338,6 +354,21 @@ public static MassFlow FromTonnesPerDay(double tonnesperday) } } + /// + /// Get nullable MassFlow from nullable KilogramsPerHour. + /// + public static MassFlow? FromKilogramsPerHour(double? kilogramsperhour) + { + if (kilogramsperhour.HasValue) + { + return FromKilogramsPerHour(kilogramsperhour.Value); + } + else + { + return null; + } + } + /// /// Get nullable MassFlow from nullable KilogramsPerSecond. /// @@ -435,6 +466,8 @@ public static MassFlow From(double val, MassFlowUnit fromUnit) return FromGramsPerSecond(val); case MassFlowUnit.HectogramPerSecond: return FromHectogramsPerSecond(val); + case MassFlowUnit.KilogramPerHour: + return FromKilogramsPerHour(val); case MassFlowUnit.KilogramPerSecond: return FromKilogramsPerSecond(val); case MassFlowUnit.MicrogramPerSecond: @@ -476,6 +509,8 @@ public static MassFlow From(double val, MassFlowUnit fromUnit) return FromGramsPerSecond(value.Value); case MassFlowUnit.HectogramPerSecond: return FromHectogramsPerSecond(value.Value); + case MassFlowUnit.KilogramPerHour: + return FromKilogramsPerHour(value.Value); case MassFlowUnit.KilogramPerSecond: return FromKilogramsPerSecond(value.Value); case MassFlowUnit.MicrogramPerSecond: @@ -650,6 +685,8 @@ public double As(MassFlowUnit unit) return GramsPerSecond; case MassFlowUnit.HectogramPerSecond: return HectogramsPerSecond; + case MassFlowUnit.KilogramPerHour: + return KilogramsPerHour; case MassFlowUnit.KilogramPerSecond: return KilogramsPerSecond; case MassFlowUnit.MicrogramPerSecond: diff --git a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs index e322d949f5..9e6815f862 100644 --- a/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs +++ b/UnitsNet/GeneratedCode/UnitSystem.Default.g.cs @@ -1179,6 +1179,12 @@ private static readonly ReadOnlyCollection DefaultLocalization { new AbbreviationsForCulture("en-US", "hg/S"), }), + new CulturesForEnumValue((int) MassFlowUnit.KilogramPerHour, + new[] + { + new AbbreviationsForCulture("en-US", "kg/h"), + new AbbreviationsForCulture("ru-RU", "кг/ч"), + }), new CulturesForEnumValue((int) MassFlowUnit.KilogramPerSecond, new[] { diff --git a/UnitsNet/Scripts/UnitDefinitions/MassFlow.json b/UnitsNet/Scripts/UnitDefinitions/MassFlow.json index 00b615bd65..db48579eeb 100644 --- a/UnitsNet/Scripts/UnitDefinitions/MassFlow.json +++ b/UnitsNet/Scripts/UnitDefinitions/MassFlow.json @@ -1,4 +1,4 @@ -{ +{ "Name": "MassFlow", "BaseUnit": "GramPerSecond", "XmlDoc": "Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time).", @@ -16,6 +16,22 @@ } ] }, + { + "SingularName": "KilogramPerHour", + "PluralName": "KilogramsPerHour", + "FromUnitToBaseFunc": "x*0.277778", + "FromBaseToUnitFunc": "x/0.277778", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "kg/h" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "кг/ч" ] + } + ] + }, { "SingularName": "TonnePerDay", "PluralName": "TonnesPerDay",