Skip to content

Commit 2bf1b27

Browse files
committed
Rename plural of percent.
Using singular name in plural form sounded most natural, both alternatives are valid. * Regenerate code and tests.
1 parent 81a0988 commit 2bf1b27

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

Src/UnitsNet/GeneratedCode/Ratio.g.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ public double PartsPerTrillions
8181
}
8282

8383
/// <summary>
84-
/// Get Ratio in Percents.
84+
/// Get Ratio in Percent.
8585
/// </summary>
86-
/// <remarks>Example: x = (y - b) / a where x is value in Percents and y is value in base unit DecimalFractions.</remarks>
87-
public double Percents
86+
/// <remarks>Example: x = (y - b) / a where x is value in Percent and y is value in base unit DecimalFractions.</remarks>
87+
public double Percent
8888
{
8989
get { return DecimalFractions / 0.01; }
9090
}
@@ -144,12 +144,12 @@ public static Ratio FromPartsPerTrillions(double partspertrillions)
144144
}
145145

146146
/// <summary>
147-
/// Get Ratio from Percents.
147+
/// Get Ratio from Percent.
148148
/// </summary>
149-
/// <remarks>Example: y = ax + b where x is value in Percents and y is value in base unit DecimalFractions.</remarks>
150-
public static Ratio FromPercents(double percents)
149+
/// <remarks>Example: y = ax + b where x is value in Percent and y is value in base unit DecimalFractions.</remarks>
150+
public static Ratio FromPercent(double percent)
151151
{
152-
return new Ratio(0.01 * percents);
152+
return new Ratio(0.01 * percent);
153153
}
154154

155155
/// <summary>
@@ -173,7 +173,7 @@ public static Ratio From(double value, RatioUnit fromUnit)
173173
case RatioUnit.PartsPerTrillion:
174174
return FromPartsPerTrillions(value);
175175
case RatioUnit.Percent:
176-
return FromPercents(value);
176+
return FromPercent(value);
177177

178178
default:
179179
throw new NotImplementedException("fromUnit: " + fromUnit);
@@ -316,7 +316,7 @@ public double As(RatioUnit unit)
316316
case RatioUnit.PartsPerTrillion:
317317
return PartsPerTrillions;
318318
case RatioUnit.Percent:
319-
return Percents;
319+
return Percent;
320320

321321
default:
322322
throw new NotImplementedException("unit: " + unit);

Src/UnitsNet/Units/RatioUnit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public enum RatioUnit
1717

1818
[I18n("en-US", "")]
1919
[I18n("ru-RU", "")]
20-
[Ratio(1e-2)]
20+
[Ratio(1e-2, "Percent")]
2121
Percent,
2222

2323
[I18n("en-US", "")]

Tests/CustomCode/RatioTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public override double PartsPerTrillionsInOneDecimalFraction
4949
get { return 1e12; }
5050
}
5151

52-
public override double PercentsInOneDecimalFraction
52+
public override double PercentInOneDecimalFraction
5353
{
5454
get { return 100; }
55-
}
55+
}
5656
}
5757
}

Tests/GeneratedCode/RatioTestsBase.g.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public abstract partial class RatioTestsBase
4242
public abstract double PartsPerMillionsInOneDecimalFraction { get; }
4343
public abstract double PartsPerThousandsInOneDecimalFraction { get; }
4444
public abstract double PartsPerTrillionsInOneDecimalFraction { get; }
45-
public abstract double PercentsInOneDecimalFraction { get; }
45+
public abstract double PercentInOneDecimalFraction { get; }
4646

4747
[Test]
4848
public void DecimalFractionToRatioUnits()
@@ -53,7 +53,7 @@ public void DecimalFractionToRatioUnits()
5353
Assert.AreEqual(PartsPerMillionsInOneDecimalFraction, decimalfraction.PartsPerMillions, Delta);
5454
Assert.AreEqual(PartsPerThousandsInOneDecimalFraction, decimalfraction.PartsPerThousands, Delta);
5555
Assert.AreEqual(PartsPerTrillionsInOneDecimalFraction, decimalfraction.PartsPerTrillions, Delta);
56-
Assert.AreEqual(PercentsInOneDecimalFraction, decimalfraction.Percents, Delta);
56+
Assert.AreEqual(PercentInOneDecimalFraction, decimalfraction.Percent, Delta);
5757
}
5858

5959
[Test]
@@ -64,7 +64,7 @@ public void FromValueAndUnit()
6464
Assert.AreEqual(1, Ratio.From(1, RatioUnit.PartsPerMillion).PartsPerMillions, Delta);
6565
Assert.AreEqual(1, Ratio.From(1, RatioUnit.PartsPerThousand).PartsPerThousands, Delta);
6666
Assert.AreEqual(1, Ratio.From(1, RatioUnit.PartsPerTrillion).PartsPerTrillions, Delta);
67-
Assert.AreEqual(1, Ratio.From(1, RatioUnit.Percent).Percents, Delta);
67+
Assert.AreEqual(1, Ratio.From(1, RatioUnit.Percent).Percent, Delta);
6868
}
6969

7070

@@ -77,7 +77,7 @@ public void As()
7777
Assert.AreEqual(PartsPerMillionsInOneDecimalFraction, decimalfraction.As(RatioUnit.PartsPerMillion), Delta);
7878
Assert.AreEqual(PartsPerThousandsInOneDecimalFraction, decimalfraction.As(RatioUnit.PartsPerThousand), Delta);
7979
Assert.AreEqual(PartsPerTrillionsInOneDecimalFraction, decimalfraction.As(RatioUnit.PartsPerTrillion), Delta);
80-
Assert.AreEqual(PercentsInOneDecimalFraction, decimalfraction.As(RatioUnit.Percent), Delta);
80+
Assert.AreEqual(PercentInOneDecimalFraction, decimalfraction.As(RatioUnit.Percent), Delta);
8181
}
8282

8383
[Test]
@@ -89,7 +89,7 @@ public void ConversionRoundTrip()
8989
Assert.AreEqual(1, Ratio.FromPartsPerMillions(decimalfraction.PartsPerMillions).DecimalFractions, Delta);
9090
Assert.AreEqual(1, Ratio.FromPartsPerThousands(decimalfraction.PartsPerThousands).DecimalFractions, Delta);
9191
Assert.AreEqual(1, Ratio.FromPartsPerTrillions(decimalfraction.PartsPerTrillions).DecimalFractions, Delta);
92-
Assert.AreEqual(1, Ratio.FromPercents(decimalfraction.Percents).DecimalFractions, Delta);
92+
Assert.AreEqual(1, Ratio.FromPercent(decimalfraction.Percent).DecimalFractions, Delta);
9393
}
9494

9595
[Test]

0 commit comments

Comments
 (0)