-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68a3b9c
commit dce6d87
Showing
8 changed files
with
103 additions
and
8 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace Gu.Units.Tests | ||
{ | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
|
||
using NUnit.Framework; | ||
|
||
public partial class LengthTests | ||
{ | ||
public static IReadOnlyList<ConversionData> ConversionSource { get; } = new[] | ||
{ | ||
new ConversionData("25.4 mm", "1 in"), | ||
new ConversionData("0.0254 m", "1 in"), | ||
new ConversionData("12 in", "1 ft", status:ConversionData.GenerationStatus.NotGenerated), | ||
new ConversionData("1 ft", "0.3048 m",status:ConversionData.GenerationStatus.NotGenerated), | ||
new ConversionData("1 m", "100 cm"), | ||
new ConversionData("1 m", "1000 mm"), | ||
new ConversionData("1 km", "1000 m"), | ||
new ConversionData("1 mi", "1.609344 km"), | ||
new ConversionData("1 mi", "1760 yd"), | ||
}; | ||
|
||
[TestCaseSource(nameof(ConversionSource))] | ||
public void Conversion(ConversionData data) | ||
{ | ||
if (data.Status == ConversionData.GenerationStatus.NotGenerated) | ||
{ | ||
Assert.Inconclusive(data.ToString()); | ||
} | ||
|
||
var l1 = Length.Parse(data.From, CultureInfo.InvariantCulture); | ||
var l2 = Length.Parse(data.To, CultureInfo.InvariantCulture); | ||
if (data.Exactly) | ||
{ | ||
Assert.AreEqual(l1, l2); | ||
} | ||
else | ||
{ | ||
Assert.AreEqual(l1.ToString(), l2.ToString()); | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace Gu.Units.Tests | ||
{ | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
|
||
using NUnit.Framework; | ||
|
||
public class TemperatureTests | ||
{ | ||
public static IReadOnlyList<ConversionData> ConversionSource { get; } = new[] | ||
{ | ||
new ConversionData("0.01°C", "273.16K", false), | ||
new ConversionData("32.018°F", "273.16K", false), | ||
new ConversionData("-40°F", "-40°C", false), | ||
}; | ||
|
||
[TestCaseSource(nameof(ConversionSource))] | ||
public void Conversion(ConversionData data) | ||
{ | ||
if (data.Status == ConversionData.GenerationStatus.NotGenerated) | ||
{ | ||
Assert.Inconclusive(data.ToString()); | ||
} | ||
|
||
var t1 = Temperature.Parse(data.From, CultureInfo.InvariantCulture); | ||
var t2 = Temperature.Parse(data.To, CultureInfo.InvariantCulture); | ||
if (data.Exactly) | ||
{ | ||
Assert.AreEqual(t1, t2); | ||
} | ||
else | ||
{ | ||
Assert.AreEqual(t1.ToString(), t2.ToString()); | ||
} | ||
} | ||
} | ||
} |
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
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