mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[PTRun][Unit]Support for plural units and improve alternative spellings (#19961)
* Upgrade UnitsNet package to a version that supports plural * Add support for plurals Fix metre conversion Add and update unit tests
This commit is contained in:
@@ -43,6 +43,16 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
||||
CollectionAssert.AreEqual(expectedResult, input);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(new string[] { "1", "metre", "in", "metre" }, new object[] { new string[] { "1", "meter", "in", "meter" } })]
|
||||
[DataRow(new string[] { "1", "centimetre", "in", "kilometre" }, new object[] { new string[] { "1", "centimeter", "in", "kilometer" } })]
|
||||
[DataRow(new string[] { "1", "metres", "in", "kilometres" }, new object[] { new string[] { "1", "meters", "in", "kilometers" } })]
|
||||
public void HandlesMetreVsMeterNotation(string[] input, string[] expectedResult)
|
||||
{
|
||||
InputInterpreter.MetreToMeter(ref input);
|
||||
CollectionAssert.AreEqual(expectedResult, input);
|
||||
}
|
||||
|
||||
[DataTestMethod]
|
||||
[DataRow(new string[] { "5", "CeLsIuS", "in", "faHrenheiT" }, new object[] { new string[] { "5", "DegreeCelsius", "in", "DegreeFahrenheit" } })]
|
||||
[DataRow(new string[] { "5", "f", "in", "celsius" }, new object[] { new string[] { "5", "<22>f", "in", "DegreeCelsius" } })]
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
||||
public void HandleTemperature()
|
||||
{
|
||||
var convertModel = new ConvertModel(1, "DegreeCelsius", "DegreeFahrenheit");
|
||||
double result = UnitHandler.ConvertInput(convertModel, UnitsNet.QuantityType.Temperature);
|
||||
double result = UnitHandler.ConvertInput(convertModel, UnitsNet.Temperature.Info);
|
||||
Assert.AreEqual(33.79999999999999d, result);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
||||
public void HandleLength()
|
||||
{
|
||||
var convertModel = new ConvertModel(1, "meter", "centimeter");
|
||||
double result = UnitHandler.ConvertInput(convertModel, UnitsNet.QuantityType.Length);
|
||||
double result = UnitHandler.ConvertInput(convertModel, UnitsNet.Length.Info);
|
||||
Assert.AreEqual(100, result);
|
||||
}
|
||||
|
||||
@@ -30,15 +30,23 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter.UnitTest
|
||||
public void HandleNanometerToKilometer()
|
||||
{
|
||||
var convertModel = new ConvertModel(1, "nanometer", "kilometer");
|
||||
double result = UnitHandler.ConvertInput(convertModel, UnitsNet.QuantityType.Length);
|
||||
double result = UnitHandler.ConvertInput(convertModel, UnitsNet.Length.Info);
|
||||
Assert.AreEqual(1E-12, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void HandlePlurals()
|
||||
{
|
||||
var convertModel = new ConvertModel(1, "meters", "centimeters");
|
||||
double result = UnitHandler.ConvertInput(convertModel, UnitsNet.Length.Info);
|
||||
Assert.AreEqual(100, result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void HandlesByteCapitals()
|
||||
{
|
||||
var convertModel = new ConvertModel(1, "kB", "kb");
|
||||
double result = UnitHandler.ConvertInput(convertModel, UnitsNet.QuantityType.Information);
|
||||
double result = UnitHandler.ConvertInput(convertModel, UnitsNet.Information.Info);
|
||||
Assert.AreEqual(8, result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user