-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added power category with mechanical and metrical horse power
- Loading branch information
1 parent
aaa4554
commit 14c4f82
Showing
4 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// <auto-generated> | ||
// This code was generated by the UnitCodeGenerator tool | ||
// | ||
// Changes to this file will be lost if the code is regenerated | ||
// </auto-generated> | ||
|
||
using NUnit.Framework; | ||
using FsCheck; | ||
using PropertyAttribute = FsCheck.NUnit.PropertyAttribute; | ||
|
||
namespace PutridParrot.Units.Tests | ||
{ | ||
public class MechanicalHorsePowerTests | ||
{ | ||
[Property] | ||
public void FromMechanicalHorsePowerToMetricHorsePowerAndBack() | ||
{ | ||
Prop.ForAll<int>(value => | ||
{ | ||
var convertTo = Power.MechanicalHorsePower.ToMetricHorsePower(value); | ||
var convertBack = Power.MetricHorsePower.ToMechanicalHorsePower(convertTo); | ||
return Is.EqualTo(convertBack).Within(0.01).ApplyTo(value).IsSuccess; | ||
}).QuickCheckThrowOnFailure(); | ||
} | ||
|
||
[TestCase(65.0971, 65.9999749)] | ||
[TestCase(121.317, 122.9996)] | ||
[TestCase(86.7962, 88.0)] | ||
public void ConvertKnownMechanicalHorsePowerToMetricHorsePower(double input, double expectation) | ||
{ | ||
var result = Power.MechanicalHorsePower.ToMetricHorsePower(input); | ||
Assert.AreEqual(expectation, result, 0.01); | ||
} | ||
|
||
} | ||
public class MetricHorsePowerTests | ||
{ | ||
[Property] | ||
public void FromMetricHorsePowerToMechanicalHorsePowerAndBack() | ||
{ | ||
Prop.ForAll<int>(value => | ||
{ | ||
var convertTo = Power.MetricHorsePower.ToMechanicalHorsePower(value); | ||
var convertBack = Power.MechanicalHorsePower.ToMetricHorsePower(convertTo); | ||
return Is.EqualTo(convertBack).Within(0.01).ApplyTo(value).IsSuccess; | ||
}).QuickCheckThrowOnFailure(); | ||
} | ||
|
||
[TestCase(126.734, 125.0)] | ||
[TestCase(91.2483, 90.0)] | ||
[TestCase(425.825, 419.9997)] | ||
public void ConvertKnownMetricHorsePowerToMechanicalHorsePower(double input, double expectation) | ||
{ | ||
var result = Power.MetricHorsePower.ToMechanicalHorsePower(input); | ||
Assert.AreEqual(expectation, result, 0.01); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// <auto-generated> | ||
// This code was generated by the UnitCodeGenerator tool | ||
// | ||
// Changes to this file will be lost if the code is regenerated | ||
// </auto-generated> | ||
|
||
namespace PutridParrot.Units | ||
{ | ||
/// <summary> | ||
/// Power conversion functions | ||
/// </summary> | ||
public static class Power | ||
{ | ||
/// <summary> | ||
/// Mechanical Horse Power conversion functions | ||
/// </summary> | ||
public static class MechanicalHorsePower | ||
{ | ||
/// <summary> | ||
/// Converts the supplied Mechanical Horse Power value to Metric Horse Power | ||
/// </summary> | ||
/// <param name="value">The Mechanical Horse Power input value</param> | ||
/// <returns>The value in Metric Horse Power</returns> | ||
public static double ToMetricHorsePower(double value) => value * 1.013869665424; | ||
} | ||
/// <summary> | ||
/// Metric Horse Power conversion functions | ||
/// </summary> | ||
public static class MetricHorsePower | ||
{ | ||
/// <summary> | ||
/// Converts the supplied Metric Horse Power value to Mechanical Horse Power | ||
/// </summary> | ||
/// <param name="value">The Metric Horse Power input value</param> | ||
/// <returns>The value in Mechanical Horse Power</returns> | ||
public static double ToMechanicalHorsePower(double value) => value / 1.013869665424; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters