Skip to content

Commit 8d06bbc

Browse files
committed
Merge pull request #164 from eriove/feature/minandmaxvalue
Add Min and MaxValue to unit classes
2 parents 49101e8 + 9fb952b commit 8d06bbc

39 files changed

+838
-0
lines changed

UnitsNet.Tests/CustomCode/InformationTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,17 @@ public void OneKBHas1000Bytes()
8484
{
8585
Assert.AreEqual(1000, Information.FromKilobytes(1).Bytes);
8686
}
87+
88+
[Test]
89+
public void MaxValueIsCorrectForUnitWithBaseTypeDecimal()
90+
{
91+
Assert.AreEqual(decimal.MaxValue, Information.MaxValue.Bits);
92+
}
93+
94+
[Test]
95+
public void MinValueIsCorrectForUnitWithBaseTypeDecimal()
96+
{
97+
Assert.AreEqual(decimal.MinValue, Information.MinValue.Bits);
98+
}
8799
}
88100
}

UnitsNet.Tests/CustomCode/LengthTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,17 @@ public void ToStringReturnsCorrectNumberAndUnitWithCentimeterAsDefualtUnit()
123123
Length.ToStringDefaultUnit = oldUnit;
124124
Assert.AreEqual("2 cm", valueString);
125125
}
126+
127+
[Test]
128+
public void MaxValueIsCorrectForUnitWithBaseTypeDouble()
129+
{
130+
Assert.AreEqual(double.MaxValue, Length.MaxValue.Meters);
131+
}
132+
133+
[Test]
134+
public void MinValueIsCorrectForUnitWithBaseTypeDouble()
135+
{
136+
Assert.AreEqual(double.MinValue, Length.MinValue.Meters);
137+
}
126138
}
127139
}

UnitsNet/GeneratedCode/UnitClasses/Acceleration.g.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,5 +828,27 @@ public string ToString(AccelerationUnit unit, [CanBeNull] Culture culture, [NotN
828828
object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
829829
return string.Format(formatProvider, format, formatArgs);
830830
}
831+
832+
/// <summary>
833+
/// Represents the largest possible value of Acceleration
834+
/// </summary>
835+
public static Acceleration MaxValue
836+
{
837+
get
838+
{
839+
return new Acceleration(double.MaxValue);
840+
}
841+
}
842+
843+
/// <summary>
844+
/// Represents the smallest possible value of Acceleration
845+
/// </summary>
846+
public static Acceleration MinValue
847+
{
848+
get
849+
{
850+
return new Acceleration(double.MinValue);
851+
}
852+
}
831853
}
832854
}

UnitsNet/GeneratedCode/UnitClasses/AmplitudeRatio.g.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,5 +688,27 @@ public string ToString(AmplitudeRatioUnit unit, [CanBeNull] Culture culture, [No
688688
object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
689689
return string.Format(formatProvider, format, formatArgs);
690690
}
691+
692+
/// <summary>
693+
/// Represents the largest possible value of AmplitudeRatio
694+
/// </summary>
695+
public static AmplitudeRatio MaxValue
696+
{
697+
get
698+
{
699+
return new AmplitudeRatio(double.MaxValue);
700+
}
701+
}
702+
703+
/// <summary>
704+
/// Represents the smallest possible value of AmplitudeRatio
705+
/// </summary>
706+
public static AmplitudeRatio MinValue
707+
{
708+
get
709+
{
710+
return new AmplitudeRatio(double.MinValue);
711+
}
712+
}
691713
}
692714
}

UnitsNet/GeneratedCode/UnitClasses/Angle.g.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,5 +1050,27 @@ public string ToString(AngleUnit unit, [CanBeNull] Culture culture, [NotNull] st
10501050
object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
10511051
return string.Format(formatProvider, format, formatArgs);
10521052
}
1053+
1054+
/// <summary>
1055+
/// Represents the largest possible value of Angle
1056+
/// </summary>
1057+
public static Angle MaxValue
1058+
{
1059+
get
1060+
{
1061+
return new Angle(double.MaxValue);
1062+
}
1063+
}
1064+
1065+
/// <summary>
1066+
/// Represents the smallest possible value of Angle
1067+
/// </summary>
1068+
public static Angle MinValue
1069+
{
1070+
get
1071+
{
1072+
return new Angle(double.MinValue);
1073+
}
1074+
}
10531075
}
10541076
}

UnitsNet/GeneratedCode/UnitClasses/Area.g.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,5 +939,27 @@ public string ToString(AreaUnit unit, [CanBeNull] Culture culture, [NotNull] str
939939
object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
940940
return string.Format(formatProvider, format, formatArgs);
941941
}
942+
943+
/// <summary>
944+
/// Represents the largest possible value of Area
945+
/// </summary>
946+
public static Area MaxValue
947+
{
948+
get
949+
{
950+
return new Area(double.MaxValue);
951+
}
952+
}
953+
954+
/// <summary>
955+
/// Represents the smallest possible value of Area
956+
/// </summary>
957+
public static Area MinValue
958+
{
959+
get
960+
{
961+
return new Area(double.MinValue);
962+
}
963+
}
942964
}
943965
}

UnitsNet/GeneratedCode/UnitClasses/BrakeSpecificFuelConsumption.g.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,5 +680,27 @@ public string ToString(BrakeSpecificFuelConsumptionUnit unit, [CanBeNull] Cultur
680680
object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
681681
return string.Format(formatProvider, format, formatArgs);
682682
}
683+
684+
/// <summary>
685+
/// Represents the largest possible value of BrakeSpecificFuelConsumption
686+
/// </summary>
687+
public static BrakeSpecificFuelConsumption MaxValue
688+
{
689+
get
690+
{
691+
return new BrakeSpecificFuelConsumption(double.MaxValue);
692+
}
693+
}
694+
695+
/// <summary>
696+
/// Represents the smallest possible value of BrakeSpecificFuelConsumption
697+
/// </summary>
698+
public static BrakeSpecificFuelConsumption MinValue
699+
{
700+
get
701+
{
702+
return new BrakeSpecificFuelConsumption(double.MinValue);
703+
}
704+
}
683705
}
684706
}

UnitsNet/GeneratedCode/UnitClasses/Density.g.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,5 +939,27 @@ public string ToString(DensityUnit unit, [CanBeNull] Culture culture, [NotNull]
939939
object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
940940
return string.Format(formatProvider, format, formatArgs);
941941
}
942+
943+
/// <summary>
944+
/// Represents the largest possible value of Density
945+
/// </summary>
946+
public static Density MaxValue
947+
{
948+
get
949+
{
950+
return new Density(double.MaxValue);
951+
}
952+
}
953+
954+
/// <summary>
955+
/// Represents the smallest possible value of Density
956+
/// </summary>
957+
public static Density MinValue
958+
{
959+
get
960+
{
961+
return new Density(double.MinValue);
962+
}
963+
}
942964
}
943965
}

UnitsNet/GeneratedCode/UnitClasses/Duration.g.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,5 +939,27 @@ public string ToString(DurationUnit unit, [CanBeNull] Culture culture, [NotNull]
939939
object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
940940
return string.Format(formatProvider, format, formatArgs);
941941
}
942+
943+
/// <summary>
944+
/// Represents the largest possible value of Duration
945+
/// </summary>
946+
public static Duration MaxValue
947+
{
948+
get
949+
{
950+
return new Duration(double.MaxValue);
951+
}
952+
}
953+
954+
/// <summary>
955+
/// Represents the smallest possible value of Duration
956+
/// </summary>
957+
public static Duration MinValue
958+
{
959+
get
960+
{
961+
return new Duration(double.MinValue);
962+
}
963+
}
942964
}
943965
}

UnitsNet/GeneratedCode/UnitClasses/DynamicViscosity.g.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,5 +754,27 @@ public string ToString(DynamicViscosityUnit unit, [CanBeNull] Culture culture, [
754754
object[] formatArgs = UnitFormatter.GetFormatArgs(unit, value, formatProvider, args);
755755
return string.Format(formatProvider, format, formatArgs);
756756
}
757+
758+
/// <summary>
759+
/// Represents the largest possible value of DynamicViscosity
760+
/// </summary>
761+
public static DynamicViscosity MaxValue
762+
{
763+
get
764+
{
765+
return new DynamicViscosity(double.MaxValue);
766+
}
767+
}
768+
769+
/// <summary>
770+
/// Represents the smallest possible value of DynamicViscosity
771+
/// </summary>
772+
public static DynamicViscosity MinValue
773+
{
774+
get
775+
{
776+
return new DynamicViscosity(double.MinValue);
777+
}
778+
}
757779
}
758780
}

0 commit comments

Comments
 (0)