Skip to content

Commit b748d21

Browse files
author
tongbong
committed
Add more units for ForceChangeRate
1 parent b5c5cf9 commit b748d21

File tree

6 files changed

+199
-1
lines changed

6 files changed

+199
-1
lines changed

UnitsNet.Tests/CustomCode/ForceChangeRateTests.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ namespace UnitsNet.Tests.CustomCode
2323
{
2424
public class ForceChangeRateTests : ForceChangeRateTestsBase
2525
{
26-
// TODO Override properties in base class here
26+
protected override double KilonewtonsPerSecondInOneNewtonPerSecond => 1E-3;
2727
protected override double NewtonsPerSecondInOneNewtonPerSecond => 1;
28+
protected override double DecinewtonsPerSecondInOneNewtonPerSecond => 1E1;
29+
protected override double CentinewtonsPerSecondInOneNewtonPerSecond => 1E2;
30+
protected override double MillinewtonsPerSecondInOneNewtonPerSecond => 1E3;
31+
protected override double MicronewtonsPerSecondInOneNewtonPerSecond => 1E6;
32+
protected override double NanonewtonsPerSecondInOneNewtonPerSecond => 1E9;
2833
}
2934
}

UnitsNet.Tests/GeneratedCode/ForceChangeRateTestsBase.g.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,72 @@ namespace UnitsNet.Tests
3636
// ReSharper disable once PartialTypeWithSinglePart
3737
public abstract partial class ForceChangeRateTestsBase
3838
{
39+
protected abstract double CentinewtonsPerSecondInOneNewtonPerSecond { get; }
40+
protected abstract double DecinewtonsPerSecondInOneNewtonPerSecond { get; }
41+
protected abstract double KilonewtonsPerSecondInOneNewtonPerSecond { get; }
42+
protected abstract double MicronewtonsPerSecondInOneNewtonPerSecond { get; }
43+
protected abstract double MillinewtonsPerSecondInOneNewtonPerSecond { get; }
44+
protected abstract double NanonewtonsPerSecondInOneNewtonPerSecond { get; }
3945
protected abstract double NewtonsPerSecondInOneNewtonPerSecond { get; }
4046

4147
// ReSharper disable VirtualMemberNeverOverriden.Global
48+
protected virtual double CentinewtonsPerSecondTolerance { get { return 1e-5; } }
49+
protected virtual double DecinewtonsPerSecondTolerance { get { return 1e-5; } }
50+
protected virtual double KilonewtonsPerSecondTolerance { get { return 1e-5; } }
51+
protected virtual double MicronewtonsPerSecondTolerance { get { return 1e-5; } }
52+
protected virtual double MillinewtonsPerSecondTolerance { get { return 1e-5; } }
53+
protected virtual double NanonewtonsPerSecondTolerance { get { return 1e-5; } }
4254
protected virtual double NewtonsPerSecondTolerance { get { return 1e-5; } }
4355
// ReSharper restore VirtualMemberNeverOverriden.Global
4456

4557
[Test]
4658
public void NewtonPerSecondToForceChangeRateUnits()
4759
{
4860
ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1);
61+
Assert.AreEqual(CentinewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.CentinewtonsPerSecond, CentinewtonsPerSecondTolerance);
62+
Assert.AreEqual(DecinewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.DecinewtonsPerSecond, DecinewtonsPerSecondTolerance);
63+
Assert.AreEqual(KilonewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.KilonewtonsPerSecond, KilonewtonsPerSecondTolerance);
64+
Assert.AreEqual(MicronewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.MicronewtonsPerSecond, MicronewtonsPerSecondTolerance);
65+
Assert.AreEqual(MillinewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.MillinewtonsPerSecond, MillinewtonsPerSecondTolerance);
66+
Assert.AreEqual(NanonewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.NanonewtonsPerSecond, NanonewtonsPerSecondTolerance);
4967
Assert.AreEqual(NewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.NewtonsPerSecond, NewtonsPerSecondTolerance);
5068
}
5169

5270
[Test]
5371
public void FromValueAndUnit()
5472
{
73+
Assert.AreEqual(1, ForceChangeRate.From(1, ForceChangeRateUnit.CentinewtonPerSecond).CentinewtonsPerSecond, CentinewtonsPerSecondTolerance);
74+
Assert.AreEqual(1, ForceChangeRate.From(1, ForceChangeRateUnit.DecinewtonPerSecond).DecinewtonsPerSecond, DecinewtonsPerSecondTolerance);
75+
Assert.AreEqual(1, ForceChangeRate.From(1, ForceChangeRateUnit.KilonewtonPerSecond).KilonewtonsPerSecond, KilonewtonsPerSecondTolerance);
76+
Assert.AreEqual(1, ForceChangeRate.From(1, ForceChangeRateUnit.MicronewtonPerSecond).MicronewtonsPerSecond, MicronewtonsPerSecondTolerance);
77+
Assert.AreEqual(1, ForceChangeRate.From(1, ForceChangeRateUnit.MillinewtonPerSecond).MillinewtonsPerSecond, MillinewtonsPerSecondTolerance);
78+
Assert.AreEqual(1, ForceChangeRate.From(1, ForceChangeRateUnit.NanonewtonPerSecond).NanonewtonsPerSecond, NanonewtonsPerSecondTolerance);
5579
Assert.AreEqual(1, ForceChangeRate.From(1, ForceChangeRateUnit.NewtonPerSecond).NewtonsPerSecond, NewtonsPerSecondTolerance);
5680
}
5781

5882
[Test]
5983
public void As()
6084
{
6185
var newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1);
86+
Assert.AreEqual(CentinewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.CentinewtonPerSecond), CentinewtonsPerSecondTolerance);
87+
Assert.AreEqual(DecinewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.DecinewtonPerSecond), DecinewtonsPerSecondTolerance);
88+
Assert.AreEqual(KilonewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.KilonewtonPerSecond), KilonewtonsPerSecondTolerance);
89+
Assert.AreEqual(MicronewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.MicronewtonPerSecond), MicronewtonsPerSecondTolerance);
90+
Assert.AreEqual(MillinewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.MillinewtonPerSecond), MillinewtonsPerSecondTolerance);
91+
Assert.AreEqual(NanonewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.NanonewtonPerSecond), NanonewtonsPerSecondTolerance);
6292
Assert.AreEqual(NewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.NewtonPerSecond), NewtonsPerSecondTolerance);
6393
}
6494

6595
[Test]
6696
public void ConversionRoundTrip()
6797
{
6898
ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1);
99+
Assert.AreEqual(1, ForceChangeRate.FromCentinewtonsPerSecond(newtonpersecond.CentinewtonsPerSecond).NewtonsPerSecond, CentinewtonsPerSecondTolerance);
100+
Assert.AreEqual(1, ForceChangeRate.FromDecinewtonsPerSecond(newtonpersecond.DecinewtonsPerSecond).NewtonsPerSecond, DecinewtonsPerSecondTolerance);
101+
Assert.AreEqual(1, ForceChangeRate.FromKilonewtonsPerSecond(newtonpersecond.KilonewtonsPerSecond).NewtonsPerSecond, KilonewtonsPerSecondTolerance);
102+
Assert.AreEqual(1, ForceChangeRate.FromMicronewtonsPerSecond(newtonpersecond.MicronewtonsPerSecond).NewtonsPerSecond, MicronewtonsPerSecondTolerance);
103+
Assert.AreEqual(1, ForceChangeRate.FromMillinewtonsPerSecond(newtonpersecond.MillinewtonsPerSecond).NewtonsPerSecond, MillinewtonsPerSecondTolerance);
104+
Assert.AreEqual(1, ForceChangeRate.FromNanonewtonsPerSecond(newtonpersecond.NanonewtonsPerSecond).NewtonsPerSecond, NanonewtonsPerSecondTolerance);
69105
Assert.AreEqual(1, ForceChangeRate.FromNewtonsPerSecond(newtonpersecond.NewtonsPerSecond).NewtonsPerSecond, NewtonsPerSecondTolerance);
70106
}
71107

UnitsNet/GeneratedCode/Enums/ForceChangeRateUnit.g.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ namespace UnitsNet.Units
2525
public enum ForceChangeRateUnit
2626
{
2727
Undefined = 0,
28+
CentinewtonPerSecond,
29+
DecinewtonPerSecond,
30+
KilonewtonPerSecond,
31+
MicronewtonPerSecond,
32+
MillinewtonPerSecond,
33+
NanonewtonPerSecond,
2834
NewtonPerSecond,
2935
}
3036
}

UnitsNet/GeneratedCode/UnitClasses/ForceChangeRate.g.cs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,54 @@ public static ForceChangeRateUnit BaseUnit
5454
get { return ForceChangeRateUnit.NewtonPerSecond; }
5555
}
5656

57+
/// <summary>
58+
/// Get ForceChangeRate in CentinewtonsPerSecond.
59+
/// </summary>
60+
public double CentinewtonsPerSecond
61+
{
62+
get { return (_newtonsPerSecond) / 1e-2d; }
63+
}
64+
65+
/// <summary>
66+
/// Get ForceChangeRate in DecinewtonsPerSecond.
67+
/// </summary>
68+
public double DecinewtonsPerSecond
69+
{
70+
get { return (_newtonsPerSecond) / 1e-1d; }
71+
}
72+
73+
/// <summary>
74+
/// Get ForceChangeRate in KilonewtonsPerSecond.
75+
/// </summary>
76+
public double KilonewtonsPerSecond
77+
{
78+
get { return (_newtonsPerSecond) / 1e3d; }
79+
}
80+
81+
/// <summary>
82+
/// Get ForceChangeRate in MicronewtonsPerSecond.
83+
/// </summary>
84+
public double MicronewtonsPerSecond
85+
{
86+
get { return (_newtonsPerSecond) / 1e-6d; }
87+
}
88+
89+
/// <summary>
90+
/// Get ForceChangeRate in MillinewtonsPerSecond.
91+
/// </summary>
92+
public double MillinewtonsPerSecond
93+
{
94+
get { return (_newtonsPerSecond) / 1e-3d; }
95+
}
96+
97+
/// <summary>
98+
/// Get ForceChangeRate in NanonewtonsPerSecond.
99+
/// </summary>
100+
public double NanonewtonsPerSecond
101+
{
102+
get { return (_newtonsPerSecond) / 1e-9d; }
103+
}
104+
57105
/// <summary>
58106
/// Get ForceChangeRate in NewtonsPerSecond.
59107
/// </summary>
@@ -71,6 +119,54 @@ public static ForceChangeRate Zero
71119
get { return new ForceChangeRate(); }
72120
}
73121

122+
/// <summary>
123+
/// Get ForceChangeRate from CentinewtonsPerSecond.
124+
/// </summary>
125+
public static ForceChangeRate FromCentinewtonsPerSecond(double centinewtonspersecond)
126+
{
127+
return new ForceChangeRate((centinewtonspersecond) * 1e-2d);
128+
}
129+
130+
/// <summary>
131+
/// Get ForceChangeRate from DecinewtonsPerSecond.
132+
/// </summary>
133+
public static ForceChangeRate FromDecinewtonsPerSecond(double decinewtonspersecond)
134+
{
135+
return new ForceChangeRate((decinewtonspersecond) * 1e-1d);
136+
}
137+
138+
/// <summary>
139+
/// Get ForceChangeRate from KilonewtonsPerSecond.
140+
/// </summary>
141+
public static ForceChangeRate FromKilonewtonsPerSecond(double kilonewtonspersecond)
142+
{
143+
return new ForceChangeRate((kilonewtonspersecond) * 1e3d);
144+
}
145+
146+
/// <summary>
147+
/// Get ForceChangeRate from MicronewtonsPerSecond.
148+
/// </summary>
149+
public static ForceChangeRate FromMicronewtonsPerSecond(double micronewtonspersecond)
150+
{
151+
return new ForceChangeRate((micronewtonspersecond) * 1e-6d);
152+
}
153+
154+
/// <summary>
155+
/// Get ForceChangeRate from MillinewtonsPerSecond.
156+
/// </summary>
157+
public static ForceChangeRate FromMillinewtonsPerSecond(double millinewtonspersecond)
158+
{
159+
return new ForceChangeRate((millinewtonspersecond) * 1e-3d);
160+
}
161+
162+
/// <summary>
163+
/// Get ForceChangeRate from NanonewtonsPerSecond.
164+
/// </summary>
165+
public static ForceChangeRate FromNanonewtonsPerSecond(double nanonewtonspersecond)
166+
{
167+
return new ForceChangeRate((nanonewtonspersecond) * 1e-9d);
168+
}
169+
74170
/// <summary>
75171
/// Get ForceChangeRate from NewtonsPerSecond.
76172
/// </summary>
@@ -90,6 +186,18 @@ public static ForceChangeRate From(double value, ForceChangeRateUnit fromUnit)
90186
{
91187
switch (fromUnit)
92188
{
189+
case ForceChangeRateUnit.CentinewtonPerSecond:
190+
return FromCentinewtonsPerSecond(value);
191+
case ForceChangeRateUnit.DecinewtonPerSecond:
192+
return FromDecinewtonsPerSecond(value);
193+
case ForceChangeRateUnit.KilonewtonPerSecond:
194+
return FromKilonewtonsPerSecond(value);
195+
case ForceChangeRateUnit.MicronewtonPerSecond:
196+
return FromMicronewtonsPerSecond(value);
197+
case ForceChangeRateUnit.MillinewtonPerSecond:
198+
return FromMillinewtonsPerSecond(value);
199+
case ForceChangeRateUnit.NanonewtonPerSecond:
200+
return FromNanonewtonsPerSecond(value);
93201
case ForceChangeRateUnit.NewtonPerSecond:
94202
return FromNewtonsPerSecond(value);
95203

@@ -225,6 +333,18 @@ public double As(ForceChangeRateUnit unit)
225333
{
226334
switch (unit)
227335
{
336+
case ForceChangeRateUnit.CentinewtonPerSecond:
337+
return CentinewtonsPerSecond;
338+
case ForceChangeRateUnit.DecinewtonPerSecond:
339+
return DecinewtonsPerSecond;
340+
case ForceChangeRateUnit.KilonewtonPerSecond:
341+
return KilonewtonsPerSecond;
342+
case ForceChangeRateUnit.MicronewtonPerSecond:
343+
return MicronewtonsPerSecond;
344+
case ForceChangeRateUnit.MillinewtonPerSecond:
345+
return MillinewtonsPerSecond;
346+
case ForceChangeRateUnit.NanonewtonPerSecond:
347+
return NanonewtonsPerSecond;
228348
case ForceChangeRateUnit.NewtonPerSecond:
229349
return NewtonsPerSecond;
230350

UnitsNet/GeneratedCode/UnitSystem.Default.g.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,36 @@ private static readonly ReadOnlyCollection<UnitLocalization> DefaultLocalization
613613
new UnitLocalization(typeof (ForceChangeRateUnit),
614614
new[]
615615
{
616+
new CulturesForEnumValue((int) ForceChangeRateUnit.CentinewtonPerSecond,
617+
new[]
618+
{
619+
new AbbreviationsForCulture("en-US", "cN/s"),
620+
}),
621+
new CulturesForEnumValue((int) ForceChangeRateUnit.DecinewtonPerSecond,
622+
new[]
623+
{
624+
new AbbreviationsForCulture("en-US", "dN/s"),
625+
}),
626+
new CulturesForEnumValue((int) ForceChangeRateUnit.KilonewtonPerSecond,
627+
new[]
628+
{
629+
new AbbreviationsForCulture("en-US", "kN/s"),
630+
}),
631+
new CulturesForEnumValue((int) ForceChangeRateUnit.MicronewtonPerSecond,
632+
new[]
633+
{
634+
new AbbreviationsForCulture("en-US", "μN/s"),
635+
}),
636+
new CulturesForEnumValue((int) ForceChangeRateUnit.MillinewtonPerSecond,
637+
new[]
638+
{
639+
new AbbreviationsForCulture("en-US", "mN/s"),
640+
}),
641+
new CulturesForEnumValue((int) ForceChangeRateUnit.NanonewtonPerSecond,
642+
new[]
643+
{
644+
new AbbreviationsForCulture("en-US", "nN/s"),
645+
}),
616646
new CulturesForEnumValue((int) ForceChangeRateUnit.NewtonPerSecond,
617647
new[]
618648
{

UnitsNet/Scripts/UnitDefinitions/ForceChangeRate.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"PluralName": "NewtonsPerSecond",
99
"FromUnitToBaseFunc": "x",
1010
"FromBaseToUnitFunc": "x",
11+
"Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Kilo" ],
1112
"Localization": [
1213
{
1314
"Culture": "en-US",

0 commit comments

Comments
 (0)