本文整理汇总了C#中Cubico.UnitConverter类的典型用法代码示例。如果您正苦于以下问题:C# UnitConverter类的具体用法?C# UnitConverter怎么用?C# UnitConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnitConverter类属于Cubico命名空间,在下文中一共展示了UnitConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnitConverter_ConvertUnitsNullTest
public void UnitConverter_ConvertUnitsNullTest()
{
UnitConverter target = new UnitConverter ();
Measurement expected = new Measurement (0, Result.BadUnit);
Measurement actual = default(Measurement);
actual = target.ConvertUnits (0, null, null);
Assert.AreNotEqual (expected, actual);
Assert.AreEqual (expected.ConversionResult, actual.ConversionResult);
}
示例2: UnitConverter_ConvertUnitsEmptyTest3
public void UnitConverter_ConvertUnitsEmptyTest3()
{
UnitConverter target = new UnitConverter ();
Measurement expected = new Measurement (0, Result.BadUnit);
Measurement actual = default(Measurement);
actual = target.ConvertUnits (0, string.Empty, "m");
Assert.AreNotEqual (expected, actual);
Assert.AreEqual (expected.ConversionResult, actual.ConversionResult);
}
示例3: UnitConverter_ConvertUnits_Celcius_to_Kelvin_Test3
public void UnitConverter_ConvertUnits_Celcius_to_Kelvin_Test3()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (0);
string currentUnitName = "C";
string targetUnitName = "K";
Measurement expected = new Measurement (Convert.ToDouble (273.15), "K");
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}
示例4: UnitConverter_ConvertUnits_chain_to_ft_Test2
public void UnitConverter_ConvertUnits_chain_to_ft_Test2()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (0.999999999);
string currentUnitName = "chain";
string targetUnitName = "ft";
Measurement expected = new Measurement (Convert.ToDouble (65.999999934), "ft");
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}
示例5: UnitConverter_ConvertUnits_bit_to_gigabyte_Test
public void UnitConverter_ConvertUnits_bit_to_gigabyte_Test()
{
UnitConverter target = new UnitConverter();
double value = Convert.ToDouble(8388608);
string currentUnitName = "bit";
string targetUnitName = "gigabyte";
Measurement expected = new Measurement(Convert.ToDouble(0.0009765625), "gigabyte");
Measurement actual = default(Measurement);
actual = target.ConvertUnits(value, currentUnitName, targetUnitName);
Assert.AreEqual(expected.Value, actual.Value);
}
示例6: UnitConverter_ConvertUnits_BTUperMin_to_FtLbPerMin_Test2
public void UnitConverter_ConvertUnits_BTUperMin_to_FtLbPerMin_Test2()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (0.999999999);
string currentUnitName = "BTU/min";
string targetUnitName = "ft lb/min";
Measurement expected = new Measurement (Convert.ToDouble (778.169370189705), "ft lb/min");
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}
示例7: UnitConverter_ConvertUnits_bit_to_bit_Test
public void UnitConverter_ConvertUnits_bit_to_bit_Test()
{
UnitConverter target = new UnitConverter();
double value = Convert.ToDouble(100);
string currentUnitName = "bit";
string targetUnitName = "bit";
Measurement expected = new Measurement(Convert.ToDouble(100), "bit");
Measurement actual = default(Measurement);
actual = target.ConvertUnits(value, currentUnitName, targetUnitName);
Assert.AreEqual(expected.Value, actual.Value);
}
示例8: UnitConverter_ConvertUnits_BTUperMin_to_Horsepower_Test2
public void UnitConverter_ConvertUnits_BTUperMin_to_Horsepower_Test2()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (0.999999999);
string currentUnitName = "BTU/min";
string targetUnitName = "hp";
Measurement expected = new Measurement (Convert.ToDouble (0.023580890005749), "hp");
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}
示例9: UnitConverter_ConvertUnits_dyn_to_ng_Test
public void UnitConverter_ConvertUnits_dyn_to_ng_Test()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (100);
string currentUnitName = "dyn";
string targetUnitName = "tonnef";
Measurement expected = new Measurement (Convert.ToDouble (1.01971621E-07), "tonnef");
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}
示例10: UnitConverter
public void UnitConverter_ConvertUnits_µm_to_mile_Test()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (100);
string currentUnitName = "µm";
string targetUnitName = "mi";
Measurement expected = new Measurement (Convert.ToDouble (6.2137119E-08), "mi");
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}
示例11: UnitConverter_ConvertUnits_tonf_to_mN_Test2
public void UnitConverter_ConvertUnits_tonf_to_mN_Test2()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (0.999999999);
string currentUnitName = "tonf";
string targetUnitName = "mN";
Measurement expected = new Measurement (Convert.ToDouble (8896443.22162456), "mN");
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}
示例12: UnitConverter_ConvertUnits_yd_to_furlong_Test2
public void UnitConverter_ConvertUnits_yd_to_furlong_Test2()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (0.999999999);
string currentUnitName = "yd";
string targetUnitName = "furlong";
Measurement expected = new Measurement (Convert.ToDouble (0.004545454540909), "furlong");
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}
示例13: UnitConverter_ConvertUnits_tonnef_to_tonf_Test
public void UnitConverter_ConvertUnits_tonnef_to_tonf_Test()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (100);
string currentUnitName = "tonnef";
string targetUnitName = "tonf";
Measurement expected = new Measurement (Convert.ToDouble (110.231131092439), "tonf");
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}
示例14: UnitConverter_ConvertUnits_tonnef_to_N_Test2
public void UnitConverter_ConvertUnits_tonnef_to_N_Test2()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (0.999999999);
string currentUnitName = "tonnef";
string targetUnitName = "N";
Measurement expected = new Measurement (Convert.ToDouble (9806.64999019335), "N");
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}
示例15: UnitConverter_ConvertUnits_tonnef_to_nN_Test
public void UnitConverter_ConvertUnits_tonnef_to_nN_Test()
{
UnitConverter target = new UnitConverter ();
double value = Convert.ToDouble (100);
string currentUnitName = "tonnef";
string targetUnitName = "nN";
Measurement expected = new Measurement (Convert.ToDouble (980665000000000.0), "nN");
//should be 98066500000000, .net conversion bug
Measurement actual = default(Measurement);
actual = target.ConvertUnits (value, currentUnitName, targetUnitName);
Assert.AreEqual (expected.Value, actual.Value);
}