本文整理汇总了C#中Distance.ToInches方法的典型用法代码示例。如果您正苦于以下问题:C# Distance.ToInches方法的具体用法?C# Distance.ToInches怎么用?C# Distance.ToInches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Distance
的用法示例。
在下文中一共展示了Distance.ToInches方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToInchesWorksCorrectly
public void ConvertToInchesWorksCorrectly()
{
// Arrange
const double Millimeters = 112345d;
const double Inches = 4423.0315d;
// Act
var distance = new Distance(Millimeters);
// Assert
Assert.IsNotNull(distance);
Assert.AreEqual(Inches, Math.Round(distance.ToInches(), 4));
}
示例2: TestConvertion
public void TestConvertion()
{
// Create an object with 5 m
Distance dist = new Distance(5, DistanceUnit.Meters);
Assert.AreEqual(5, dist.Value);
Assert.AreEqual(DistanceUnit.Meters, dist.Units);
Distance feet = dist.ToFeet();
Assert.AreEqual(16.4041995, feet.Value, 0.00001);
Assert.AreEqual(DistanceUnit.Feet, feet.Units);
Distance meters = dist.ToMeters();
Assert.AreEqual(5, meters.Value);
Assert.AreEqual(DistanceUnit.Meters, meters.Units);
Distance mm = dist.ToMillimeters();
Assert.AreEqual(5000, mm.Value);
Assert.AreEqual(DistanceUnit.Millimeters, mm.Units);
Distance cm = dist.ToCentimeters();
Assert.AreEqual(500, cm.Value);
Assert.AreEqual(DistanceUnit.Centimeters, cm.Units);
Distance inch = dist.ToInches();
Assert.AreEqual(196.850394, inch.Value, 0.00001);
Assert.AreEqual(DistanceUnit.Inches, inch.Units);
Distance km = dist.ToKilometers();
Assert.AreEqual(0.005, km.Value);
Assert.AreEqual(DistanceUnit.Kilometers, km.Units);
Distance miles = dist.ToStatuteMiles();
Assert.AreEqual(0.00310685596, miles.Value, 0.00001);
Assert.AreEqual(DistanceUnit.StatuteMiles, miles.Units);
Distance nm = dist.ToNauticalMiles();
Assert.AreEqual(0.00269978402, nm.Value, 0.00001);
Assert.AreEqual(DistanceUnit.NauticalMiles, nm.Units);
}