public int CompareTo(Fitness that) { if (ReferenceEquals(this, that)) { return(0); } if (that is null) { return(1); } var value = TotalValue.CompareTo(that.TotalValue); if (value != 0) { return(value); } var weight = -TotalWeight.CompareTo(that.TotalWeight); if (weight != 0) { return(weight); } var volume = -TotalVolume.CompareTo(that.TotalVolume); return(volume); }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (Contact != null) { Contact.Validate(); } if (PalletList != null) { foreach (var element in PalletList) { if (element != null) { element.Validate(); } } } if (TotalWeight != null) { TotalWeight.Validate(); } if (SellerDeclaredValue != null) { SellerDeclaredValue.Validate(); } }
public void Constructor2ShouldStoreAndPrintValueAndSymbolWithPounds() { WeightOfSolidMatter wsm = new WeightOfSolidMatter(10, WeightUnits.Grams); TotalWeight tw = new TotalWeight(20, WeightUnits.Grams); WeightOfWater ww = new WeightOfWater(wsm, tw, WeightUnits.Pounds); Assert.AreEqual(Math.Round(ww.NumericValue, 3), 0.022); Assert.AreEqual(ww.UnitOfMeasure, WeightUnits.Pounds); }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (Contact == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Contact"); } if (PalletList == null) { throw new ValidationException(ValidationRules.CannotBeNull, "PalletList"); } if (TotalWeight == null) { throw new ValidationException(ValidationRules.CannotBeNull, "TotalWeight"); } if (PreviewFreightClass == null) { throw new ValidationException(ValidationRules.CannotBeNull, "PreviewFreightClass"); } if (AmazonReferenceId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "AmazonReferenceId"); } if (CarrierName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "CarrierName"); } if (Contact != null) { Contact.Validate(); } if (PalletList != null) { foreach (var element in PalletList) { if (element != null) { element.Validate(); } } } if (TotalWeight != null) { TotalWeight.Validate(); } if (SellerDeclaredValue != null) { SellerDeclaredValue.Validate(); } if (AmazonCalculatedValue != null) { AmazonCalculatedValue.Validate(); } if (PartneredEstimate != null) { PartneredEstimate.Validate(); } }
public void Constructor2ShouldStoreAndPrintValueAndSymbolWithKilograms() { WeightOfWater ww = new WeightOfWater(10, WeightUnits.Grams); TotalWeight tw = new TotalWeight(20, WeightUnits.Grams); WeightOfSolidMatter wsm = new WeightOfSolidMatter(ww, tw, WeightUnits.Kilograms); Assert.AreEqual(Math.Round(wsm.NumericValue, 2), .01); Assert.AreEqual(wsm.UnitOfMeasure, WeightUnits.Kilograms); }
public void Constructor1ShouldStoreAndPrintValueAndSymbol() { TotalWeight tw = new TotalWeight(10, WeightUnits.Grams); String correctAnswer = "W = 10 g"; Assert.AreEqual("W", tw.Symbol); Assert.AreEqual(tw.NumericValue, 10); Assert.AreEqual(tw.UnitOfMeasure, WeightUnits.Grams); Assert.AreEqual(correctAnswer, tw.ToString()); }
public void Constructor2ShouldStoreAndPrintValueAndSymbolWithPoundPerFootCubed() { TotalWeight tw = new TotalWeight(10, WeightUnits.Grams); TotalVolume tv = new TotalVolume(10, VolumeUnits.CubicCentimeters); TotalUnitWeight tuw = new TotalUnitWeight(tw, tv, UnitWeightUnits.PoundPerCubicFoot); Assert.AreEqual(Math.Round(tuw.NumericValue, 2), 62.43); Assert.AreEqual(tuw.UnitOfMeasure, UnitWeightUnits.PoundPerCubicFoot); Assert.AreEqual(tuw.Symbol, "𝛾_t");; }
public void Constructor3ShouldStoreAndPrintValueAndSymbolWithKilograms() { MassSpecificGravity msg = new MassSpecificGravity(10); UnitWeightOfWater uww = new UnitWeightOfWater(1, UnitWeightUnits.GramPerCubicCentimeter); TotalVolume tv = new TotalVolume(10, VolumeUnits.CubicCentimeters); TotalWeight tw = new TotalWeight(msg, uww, tv, WeightUnits.Kilograms); Assert.AreEqual("W", tw.Symbol); Assert.AreEqual(Math.Round(tw.NumericValue, 2), .10); Assert.AreEqual(tw.UnitOfMeasure, WeightUnits.Kilograms); }
public void Constructor2ShouldStoreAndPrintValueAndSymbolWithGrams() { WeightOfSolidMatter wsm = new WeightOfSolidMatter(10, WeightUnits.Grams); TotalWeight tw = new TotalWeight(20, WeightUnits.Grams); WeightOfWater ww = new WeightOfWater(wsm, tw, WeightUnits.Grams); String correctAnswer = "W_w = 10 g"; Assert.AreEqual("W_w", ww.Symbol); Assert.AreEqual(ww.NumericValue, 10); Assert.AreEqual(ww.UnitOfMeasure, WeightUnits.Grams); Assert.AreEqual(correctAnswer, ww.ToString()); }
public override string ToString() { if (!IsEmpty) { StringBuilder sb = new StringBuilder(); var n = OrderedNodes; int k = n.Count - 1; sb.AppendFormat("Path: {0} - {1}, Weight: {2}\n", n[0].Id, n[k].Id, TotalWeight.ToString("N2")); for (int i = 0; i < k; i++) { sb.AppendFormat("[{0}]-", n[i].Id); } sb.AppendFormat("[{0}]", n[k].Id); return(sb.ToString()); } else { return("Path is empty."); } }
public override int GetHashCode() { unchecked { var hashCode = AddressId.GetHashCode(); hashCode = (hashCode * 397) ^ (AnalyticsData != null ? AnalyticsData.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (BillingAddress != null ? BillingAddress.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ClientDetails != null ? ClientDetails.GetHashCode() : 0); hashCode = (hashCode * 397) ^ CreatedAt.GetHashCode(); hashCode = (hashCode * 397) ^ (CustomerHash != null ? CustomerHash.GetHashCode() : 0); hashCode = (hashCode * 397) ^ CustomerId.GetHashCode(); hashCode = (hashCode * 397) ^ (Email != null ? Email.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FirstName != null ? FirstName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ HasUncommitedChanges.GetHashCode(); hashCode = (hashCode * 397) ^ Id.GetHashCode(); hashCode = (hashCode * 397) ^ (LastName != null ? LastName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Note != null ? Note.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ProcessedAt.GetHashCode(); hashCode = (hashCode * 397) ^ (ProcessorName != null ? ProcessorName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ScheduledAt.GetHashCode(); hashCode = (hashCode * 397) ^ ShipmentsCount.GetHashCode(); hashCode = (hashCode * 397) ^ (ShippingAddress != null ? ShippingAddress.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ShopifyOrderId.GetHashCode(); hashCode = (hashCode * 397) ^ (Status != null ? Status.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SubTotal != null ? SubTotal.GetHashCode() : 0); hashCode = (hashCode * 397) ^ SubtotalPrice.GetHashCode(); hashCode = (hashCode * 397) ^ (Tags != null ? Tags.GetHashCode() : 0); hashCode = (hashCode * 397) ^ TaxLines.GetHashCode(); hashCode = (hashCode * 397) ^ (TotalDiscounts != null ? TotalDiscounts.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TotalLineItemsPrice != null ? TotalLineItemsPrice.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TotalPrice != null ? TotalPrice.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TotalRefunds != null ? TotalRefunds.GetHashCode() : 0); hashCode = (hashCode * 397) ^ TotalTax.GetHashCode(); hashCode = (hashCode * 397) ^ TotalWeight.GetHashCode(); hashCode = (hashCode * 397) ^ (TransactionId != null ? TransactionId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0); hashCode = (hashCode * 397) ^ UpdatedAt.GetHashCode(); return(hashCode); } }
/// <summary> /// Initializes a new instance of the <see cref="WeightOfSolidMatter"/> class. /// </summary> /// <param name="waterWeight">W_w in W=W_w+W_s.</param> /// <param name="totalWeight">W in W=W_w+W_s.</param> /// <param name="units">Measurement unit to hold value after initial calculation (ie kg).</param> public WeightOfSolidMatter(WeightOfWater waterWeight, TotalWeight totalWeight, WeightUnits units) : this(ConvertToUnits(totalWeight, units).NumericValue - ConvertToUnits(waterWeight, units).NumericValue, units) { }
/// <summary> /// Initializes a new instance of the <see cref="TotalUnitWeight"/> class. /// </summary> /// <param name="totalWeight">W in gamma_t=W/V.</param> /// <param name="totalVolume">V in gamma_t=W/V.</param> /// <param name="units">Measurement unit to use after construction from formula (ie g/cc).</param> public TotalUnitWeight(TotalWeight totalWeight, TotalVolume totalVolume, UnitWeightUnits units) : this(ConvertToUnits(new BaseUnitWeightScalar("𝛾", BaseWeightScalar.ConvertToUnits(totalWeight, WeightUnits.Kilograms).NumericValue / BaseVolumeScalar.ConvertToUnits(totalVolume, VolumeUnits.CubicMeters).NumericValue, UnitWeightUnits.KilogramPerMeterCubed), units).NumericValue, units) { }