public void Convert_Kilograms_and_Pounds() { double kgs_lbs = new Kilograms(12).To<Pounds>(); // 26.4555 double lbs_kgs = new Pounds(25).To<Kilograms>(); // 11.3398 Assert.AreEqual(26.4555, Math.Round(kgs_lbs, 4)); Assert.AreEqual(11.3398, Math.Round(lbs_kgs, 4)); }
public void Convert_Kilograms_and_Pounds() { double kgs_lbs = new Kilograms(12).To <Pounds>(); // 26.4555 double lbs_kgs = new Pounds(25).To <Kilograms>(); // 11.3398 Assert.AreEqual(26.4555, Math.Round(kgs_lbs, 4)); Assert.AreEqual(11.3398, Math.Round(lbs_kgs, 4)); }
public override int GetHashCode() { unchecked { // ReSharper disable NonReadonlyMemberInGetHashCode var hashCode = WeightRange.GetHashCode(); hashCode = (hashCode * 397) ^ Kilograms.GetHashCode(); hashCode = (hashCode * 397) ^ IsMetric.GetHashCode(); // ReSharper restore NonReadonlyMemberInGetHashCode return(hashCode); } }
public bool Equals(Weight other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(WeightRange == other.WeightRange && Kilograms.Equals(other.Kilograms) && IsMetric == other.IsMetric); }
public int CompareTo(Weight other) => Kilograms.CompareTo(other.Kilograms);
public bool Equals(Weight other) => Kilograms.Equals(other.Kilograms);
public void Kilograms_2_tons() { FloatCompare(0.0011023113f, Kilograms.Tons(1)); }
public void Kilograms_2_pounds() { FloatCompare(2.2046228f, Kilograms.Pounds(1)); }
public void Kilograms_2_ounces() { FloatCompare(35.273962f, Kilograms.Ounces(1)); }
public void Kilograms_2_grams() { FloatCompare(1000f, Kilograms.Grams(1)); }
private void Print() { Console.WriteLine(Formatter.GetString(OriginalValue.ToString(), ORIGINAL_TYPE, nameof(Kilograms), Kilograms.ToString("#.######"))); Console.WriteLine(Formatter.GetString(OriginalValue.ToString(), ORIGINAL_TYPE, nameof(Ounces), Ounces.ToString("#.######"))); Console.WriteLine(Formatter.GetString(OriginalValue.ToString(), ORIGINAL_TYPE, nameof(Stone), Stone.ToString("#.######"))); Console.WriteLine(); }