public void OwnershipCost_persistence_test() { DateTime now = DateTime.Now; // Get datetime without milliseconds now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind); var _vehiculebo_vehicule_ownershipcost = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Vehicule { OverHeadCost = 222222.22M, CalculatedTimeCost = 222222.22M, CalculatedDistanceCost = 222222.22M, CalculatedOwnershipCost = 222222.22M, VehiculeType = "Vehicule_VehiculeType", Volume = "Vehicule_Volume", CO2perKm = 222222.22M, AmortizationType = "Vehicule_AmortizationType", MaximumLoad = 222222.22M, }; new PersistenceSpecification <DSS3_LogisticsPoolingForUrbanDistribution.BO.OwnershipCost>(Session) .CheckProperty(p => p.VehiculePurchaseCost, 222222.22M) .CheckProperty(p => p.RefrigerationSystemCost, 222222.22M) .CheckProperty(p => p.LetteringCost, 222222.22M) .CheckProperty(p => p.InterestRate, 222222.22M) .CheckProperty(p => p.PaybackPeriod, 222222.22M) .CheckProperty(p => p.TotalDistancePerVehicule, 222222.22M) .CheckProperty(p => p.AmortizationPeriod, 222222.22M) .CheckProperty(p => p.ResidualValue, 222222.22M) .CheckProperty(p => p.UtilizationPeriod, 222222.22M) .CheckProperty(p => p.Cost, 222222.22M) .CheckReference(p => p.Vehicule, _vehiculebo_vehicule_ownershipcost) .VerifyTheMappings(); }
/// <summary> /// Returns true if self and the provided entity have the same Id values /// and the Ids are not of the default Id value /// </summary> protected bool HasSameNonDefaultIdAs(Vehicule compareTo) { return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id)); }
/// <summary> /// Copies the current object to a new instance /// </summary> /// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param> /// <param name="copiedObjects">Objects that should be reused</param> /// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param> /// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param> /// <param name="copy">Optional - An existing [Vehicule] instance to use as the destination.</param> /// <returns>A copy of the object</returns> public virtual Vehicule Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, Vehicule copy = null) { if (copiedObjects == null) { copiedObjects = new Hashtable(); } if (copy == null && copiedObjects.Contains(this)) { return((Vehicule)copiedObjects[this]); } copy = copy ?? new Vehicule(); if (!asNew) { copy.TransientId = this.TransientId; copy.Id = this.Id; } copy.OverHeadCost = this.OverHeadCost; copy.CalculatedTimeCost = this.CalculatedTimeCost; copy.CalculatedDistanceCost = this.CalculatedDistanceCost; copy.CalculatedOwnershipCost = this.CalculatedOwnershipCost; copy.VehiculeType = this.VehiculeType; copy.Volume = this.Volume; copy.CO2perKm = this.CO2perKm; copy.AmortizationType = this.AmortizationType; copy.MaximumLoad = this.MaximumLoad; if (!copiedObjects.Contains(this)) { copiedObjects.Add(this, copy); } if (deep && this.distanceCosts != null) { if (!copiedObjects.Contains(this.distanceCosts)) { if (asNew && reuseNestedObjects) { copy.DistanceCosts = this.DistanceCosts; } else if (asNew) { copy.DistanceCosts = this.DistanceCosts.Copy(deep, copiedObjects, true); } else { copy.distanceCosts = this.distanceCosts.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.DistanceCosts = (DistanceCosts)copiedObjects[this.DistanceCosts]; } else { copy.distanceCosts = (DistanceCosts)copiedObjects[this.DistanceCosts]; } } } if (deep && this.timeCosts != null) { if (!copiedObjects.Contains(this.timeCosts)) { if (asNew && reuseNestedObjects) { copy.TimeCosts = this.TimeCosts; } else if (asNew) { copy.TimeCosts = this.TimeCosts.Copy(deep, copiedObjects, true); } else { copy.timeCosts = this.timeCosts.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.TimeCosts = (TimeCosts)copiedObjects[this.TimeCosts]; } else { copy.timeCosts = (TimeCosts)copiedObjects[this.TimeCosts]; } } } if (deep && this.ownershipCost != null) { if (!copiedObjects.Contains(this.ownershipCost)) { if (asNew && reuseNestedObjects) { copy.OwnershipCost = this.OwnershipCost; } else if (asNew) { copy.OwnershipCost = this.OwnershipCost.Copy(deep, copiedObjects, true); } else { copy.ownershipCost = this.ownershipCost.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.OwnershipCost = (OwnershipCost)copiedObjects[this.OwnershipCost]; } else { copy.ownershipCost = (OwnershipCost)copiedObjects[this.OwnershipCost]; } } } if (deep && this.amortizationType1 != null) { if (!copiedObjects.Contains(this.amortizationType1)) { if (asNew && reuseNestedObjects) { copy.AmortizationType1 = this.AmortizationType1; } else if (asNew) { copy.AmortizationType1 = this.AmortizationType1.Copy(deep, copiedObjects, true); } else { copy.amortizationType1 = this.amortizationType1.Copy(deep, copiedObjects, false); } } else { if (asNew) { copy.AmortizationType1 = (AmortizationType)copiedObjects[this.AmortizationType1]; } else { copy.amortizationType1 = (AmortizationType)copiedObjects[this.AmortizationType1]; } } } return(copy); }
public void Shipment_persistence_test() { DateTime now = DateTime.Now; // Get datetime without milliseconds now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind); var _actionsbo_shippingorders_shipment = new DSS3_LogisticsPoolingForUrbanDistribution.BO.ShippingOrder { DepartureDate = now, ArrivalDate = now, Shipper = "ShippingOrder_Shipper", Carrier = "ShippingOrder_Carrier", ItemDescription = "ShippingOrder_ItemDescription", Conditions = "ShippingOrder_Conditions", AggregateVolume = 222222.22M, Priority = 1726, }; var _actionsbo_shippingorders_shipment2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.ShippingOrder { DepartureDate = now, ArrivalDate = now, Shipper = "ShippingOrder_Shipper", Carrier = "ShippingOrder_Carrier", ItemDescription = "ShippingOrder_ItemDescription", Conditions = "ShippingOrder_Conditions", AggregateVolume = 222222.22M, Priority = 8201, }; var _actionsbo_shipmentstatus_shipment = new DSS3_LogisticsPoolingForUrbanDistribution.BO.ShipmentStatus { TimeReported = now, Description = "ShipmentStatus_Description", User = "******", }; var _actionsbo_shipmentstatus_shipment2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.ShipmentStatus { TimeReported = now, Description = "ShipmentStatus_Description", User = "******", }; var _actionsbo_departurepoint_shipment = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Location { Name = "Location_Name", Street = "Location_Street", City = "Location_City", Country = "Location_Country", Number = "Location_Number", PostCode = "Location_PostCode", Label = "Location_Label", }; var _actionsbo_finaldestination_shipment_1 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Location { Name = "Location_Name", Street = "Location_Street", City = "Location_City", Country = "Location_Country", Number = "Location_Number", PostCode = "Location_PostCode", Label = "Location_Label", }; var _actionsbo_driver_shipment = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Driver { Id = 6688, UserName = "******", PasswordHash = "Driver_PasswordHash", SecurityStamp = "Driver_SecurityStamp", EmailConfirmed = true, LockoutEnabled = true, PhoneNumberConfirmed = true, TwoFactorEnabled = true, AccessFailedCount = 6962, Name = "Driver_Name", Email = "Driver_Email", PhoneNumber = "Driver_PhoneNumber", LockoutEndDate = now, }; var _actionsbo_occupiedvolume_shipment_1 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.CustomVolume { Weight = 222222.22M, }; var _actionsbo_acceptedconditions_shipment = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Condition { Description = "Condition_Description", }; var _actionsbo_acceptedconditions_shipment2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Condition { Description = "Condition_Description", }; var _actionsbo_vehiculetype_shipment = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Vehicule { OverHeadCost = 222222.22M, CalculatedTimeCost = 222222.22M, CalculatedDistanceCost = 222222.22M, CalculatedOwnershipCost = 222222.22M, VehiculeType = "Vehicule_VehiculeType", Volume = "Vehicule_Volume", CO2perKm = 222222.22M, AmortizationType = "Vehicule_AmortizationType", MaximumLoad = 222222.22M, }; var _actionsbo_path_shipment_2 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Point { LocId = 833, Time = 751, Distance = 2145, CurrentLoad = 222222.22M, }; var _actionsbo_path_shipment_22 = new DSS3_LogisticsPoolingForUrbanDistribution.BO.Point { LocId = 7501, Time = 1091, Distance = 9420, CurrentLoad = 222222.22M, }; new PersistenceSpecification <DSS3_LogisticsPoolingForUrbanDistribution.BO.Shipment>(Session) .CheckProperty(p => p.Owner, "Shipment_Owner") .CheckProperty(p => p.DepartureTime, now) .CheckProperty(p => p.Temperature, "Shipment_Temperature") .CheckProperty(p => p.LoadPercentage, 6077) .CheckProperty(p => p.TotalVolume, 222222.22M) .CheckProperty(p => p.AverageVolume, 222222.22M) .CheckProperty(p => p.MaxTravelTime, 7344) .CheckBag(p => p.ShippingOrders, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.ShippingOrder> { _actionsbo_shippingorders_shipment, _actionsbo_shippingorders_shipment2 })) .CheckBag(p => p.ShipmentStatus, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.ShipmentStatus> { _actionsbo_shipmentstatus_shipment, _actionsbo_shipmentstatus_shipment2 })) .CheckReference(p => p.DeparturePoint, _actionsbo_departurepoint_shipment) .CheckReference(p => p.FinalDestination, _actionsbo_finaldestination_shipment_1) .CheckReference(p => p.Driver, _actionsbo_driver_shipment) .CheckReference(p => p.OccupiedVolume, _actionsbo_occupiedvolume_shipment_1) .CheckBag(p => p.AcceptedConditions, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.Condition> { _actionsbo_acceptedconditions_shipment, _actionsbo_acceptedconditions_shipment2 })) .CheckReference(p => p.VehiculeType, _actionsbo_vehiculetype_shipment) .CheckBag(p => p.Path, (new List <DSS3_LogisticsPoolingForUrbanDistribution.BO.Point> { _actionsbo_path_shipment_2, _actionsbo_path_shipment_22 })) .VerifyTheMappings(); }