本文整理汇总了C#中Distance.ToMillimeters方法的典型用法代码示例。如果您正苦于以下问题:C# Distance.ToMillimeters方法的具体用法?C# Distance.ToMillimeters怎么用?C# Distance.ToMillimeters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Distance
的用法示例。
在下文中一共展示了Distance.ToMillimeters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: SubtractEqualsTakesOnesDistanceAwayFromAnother
public void SubtractEqualsTakesOnesDistanceAwayFromAnother()
{
// Arrange
const long Distance1 = 123;
const long Distance2 = 456;
const long Difference = 333;
var distance1 = new Distance(Distance1);
var distance2 = new Distance(Distance2);
// Act
distance2 -= distance1;
// Assert
Assert.IsNotNull(distance2);
Assert.AreEqual(distance2.ToMillimeters(), Difference);
}
示例3: MillimetersReturnsTheCorrectValueThroughDirectConstructor
public void MillimetersReturnsTheCorrectValueThroughDirectConstructor()
{
// Arrange
const long Millimeters = 12345;
// Act
var distance = new Distance(Millimeters);
// Assert
Assert.IsNotNull(distance);
Assert.AreEqual(Millimeters, distance.ToMillimeters());
}
示例4: PlusEqualsAddsTwoItemsTogether
public void PlusEqualsAddsTwoItemsTogether()
{
// Arrange
const long Distance1 = 123;
const long Distance2 = 456;
const long Total = 579;
var distance1 = new Distance(Distance1);
var distance2 = new Distance(Distance2);
// Act
distance1 += distance2;
// Assert
Assert.IsNotNull(distance1);
Assert.AreEqual(distance1.ToMillimeters(), Total);
}