public void CalculateDeliveryDateSameWarehouseSameDay() { using (TransactionScope scope = new TransactionScope()) { //set-up two warehouses TDCShipment tdcShipment = new TDCShipment(); Warehouse stockWarehouse = WarehouseTests.PopulateNewItem(); WarehouseTests.SaveItem(stockWarehouse); tdcShipment.StockWarehouseCode = stockWarehouse.Code; tdcShipment.DeliveryWarehouseCode = stockWarehouse.Code; tdcShipment.RequiredShipmentDate = new DateTime(2006, 07, 24); tdcShipment.OpCoCode = "HSP"; Route route = RouteTests.PopulateNewItem(); route.IsNextDay = false; route.IsSameDay = true; RouteTests.SaveItem(route); tdcShipment.RouteCode = route.Code; tdcShipment.CalculateDeliveryDate(); Assert.IsTrue(tdcShipment.EstimatedDeliveryDate == new DateTime(2006, 07, 24)); } }
public void CalculateDeliveryDate() { using (TransactionScope scope = new TransactionScope()) { TDCShipment tdcShipment = new TDCShipment(); //set-up two warehouses Warehouse stockWarehouse = WarehouseTests.PopulateNewItem(); WarehouseTests.SaveItem(stockWarehouse); tdcShipment.StockWarehouseCode = stockWarehouse.Code; Warehouse deliveryWarehouse = WarehouseTests.PopulateNewItem(); WarehouseTests.SaveItem(deliveryWarehouse); tdcShipment.DeliveryWarehouseCode = deliveryWarehouse.Code; //set-up trunker days TrunkerDay trunkerDay = new TrunkerDay(); trunkerDay.Days = 3; trunkerDay.SourceWarehouseId = tdcShipment.StockWarehouse.Id; trunkerDay.DestinationWarehouseId = tdcShipment.DeliveryWarehouse.Id; trunkerDay.UpdatedBy = "me"; trunkerDay.Id = TrunkerDaysController.SaveTrunkerDay(trunkerDay); tdcShipment.RequiredShipmentDate = new DateTime(2006, 07, 24); tdcShipment.OpCoCode = "HSP"; tdcShipment.StockWarehouseCode = tdcShipment.StockWarehouse.Code; tdcShipment.DeliveryWarehouseCode = tdcShipment.DeliveryWarehouse.Code; tdcShipment.CalculateDeliveryDate(); Assert.IsTrue(tdcShipment.EstimatedDeliveryDate == new DateTime(2006, 07, 27)); } }
public void CalculateDeliveryDateWithWeekend() { using (TransactionScope scope = new TransactionScope()) { //set-up two warehouses TDCShipment tdcShipment = new TDCShipment(); Warehouse stockWarehouse = WarehouseTests.PopulateNewItem(); WarehouseTests.SaveItem(stockWarehouse); tdcShipment.StockWarehouseCode = stockWarehouse.Code; Warehouse deliveryWarehouse = WarehouseTests.PopulateNewItem(); WarehouseTests.SaveItem(deliveryWarehouse); tdcShipment.DeliveryWarehouseCode = deliveryWarehouse.Code; //set-up non working days //saturday NonWorkingDay nonWorkingDay = new NonWorkingDay(); nonWorkingDay.NonWorkingDate = new DateTime(2006, 07, 29); nonWorkingDay.Description = "sat"; nonWorkingDay.UpdatedBy = "me"; nonWorkingDay.WarehouseId = tdcShipment.DeliveryWarehouse.Id; NonWorkingDayController.SaveNonWorkingDay(nonWorkingDay); //sunday nonWorkingDay = new NonWorkingDay(); nonWorkingDay.NonWorkingDate = new DateTime(2006, 07, 30); nonWorkingDay.Description = "sun"; nonWorkingDay.UpdatedBy = "me"; nonWorkingDay.WarehouseId = tdcShipment.DeliveryWarehouse.Id; NonWorkingDayController.SaveNonWorkingDay(nonWorkingDay); //set-up trunker days TrunkerDay trunkerDay = new TrunkerDay(); trunkerDay.Days = 3; trunkerDay.SourceWarehouseId = tdcShipment.StockWarehouse.Id; trunkerDay.DestinationWarehouseId = tdcShipment.DeliveryWarehouse.Id; trunkerDay.UpdatedBy = "me"; trunkerDay.Id = TrunkerDaysController.SaveTrunkerDay(trunkerDay); tdcShipment.RequiredShipmentDate = new DateTime(2006, 07, 26); tdcShipment.OpCoCode = "HSP"; tdcShipment.StockWarehouseCode = tdcShipment.StockWarehouse.Code; tdcShipment.DeliveryWarehouseCode = tdcShipment.DeliveryWarehouse.Code; tdcShipment.CalculateDeliveryDate(); Assert.IsTrue(tdcShipment.EstimatedDeliveryDate == new DateTime(2006, 07, 31)); } }
internal TrunkerDay PopulateNewItem() { TrunkerDay trunkerDay = new TrunkerDay(); trunkerDay.Days = 3; trunkerDay.UpdatedBy = "IanKilsby"; // Set up 2 Warehouses // First warehouse is IPS created by using the warehouse pouulate method trunkerDay.SourceWarehouse = WarehouseTests.PopulateNewItem(); trunkerDay.SourceWarehouse.Code = "IPS"; trunkerDay.SourceWarehouseId = WarehouseTests.SaveItem(trunkerDay.SourceWarehouse); // Second warehouse cannot use the populate method due to duplicate foreign keys e.g. printer etc trunkerDay.DestinationWarehouse = new Warehouse(); trunkerDay.DestinationWarehouse.Description = "London Warehouse"; trunkerDay.DestinationWarehouse.UpdatedBy = "IanKilsby"; trunkerDay.DestinationWarehouse.Contact = new Contact(); trunkerDay.DestinationWarehouse.Contact.Name = "ContactName"; trunkerDay.DestinationWarehouse.Contact.TelephoneNumber = "TelephoneNumber"; trunkerDay.DestinationWarehouse.Contact.Email = "SalesEmail"; trunkerDay.DestinationWarehouse.HasCommander = true; trunkerDay.DestinationWarehouse.HasOptrak = true; trunkerDay.DestinationWarehouse.IsTDC = true; // trunkerDay.DestinationWarehouse.PrinterName = trunkerDay.SourceWarehouse.PrinterName; //trunkerDay.DestinationWarehouse.PrinterId = trunkerDay.SourceWarehouse.Printer.Id; trunkerDay.DestinationWarehouse.OptrakRegion = trunkerDay.SourceWarehouse.OptrakRegion; trunkerDay.DestinationWarehouse.OptrakRegion.Id = trunkerDay.SourceWarehouse.RegionId; trunkerDay.DestinationWarehouse.RegionId = trunkerDay.SourceWarehouse.RegionId; trunkerDay.DestinationWarehouse.Address = new Address(); trunkerDay.DestinationWarehouse.Address.Line1 = "line1"; trunkerDay.DestinationWarehouse.Address.Line2 = "line2"; trunkerDay.DestinationWarehouse.Address.Line3 = "line3"; trunkerDay.DestinationWarehouse.Address.Line4 = "line4"; trunkerDay.DestinationWarehouse.Address.PostCode = "PostCode"; trunkerDay.DestinationWarehouse.Code = "LON"; trunkerDay.DestinationWarehouseId = WarehouseTests.SaveItem(trunkerDay.DestinationWarehouse); return(trunkerDay); }
static internal TDCShipment PopulateItem() { TDCShipment tdcShipment = new TDCShipment(); OpCoShipment opCoShipment = OpcoShipmentTests.PopulateNewItem(); try { tdcShipment.OpCoShipmentId = OpCoShipmentController.SaveShipment(opCoShipment); } catch (InValidBusinessObjectException e) { Console.Write(e.ValidatableObject.ValidationMessages); } tdcShipment.OpCoCode = opCoShipment.OpCoCode; tdcShipment.OpCoSequenceNumber = 1; tdcShipment.OpCoContact.Email = "Email"; tdcShipment.OpCoContact.Name = "Name"; tdcShipment.DespatchNumber = "Number"; tdcShipment.RequiredShipmentDate = DateTime.Now; tdcShipment.CustomerNumber = "CustNo"; tdcShipment.CustomerName = "CustomerName"; tdcShipment.CustomerReference = "ref"; tdcShipment.CustomerAddress.Line1 = "Line1"; tdcShipment.CustomerAddress.PostCode = "NN8 1NB"; tdcShipment.ShipmentNumber = "ShipNo"; tdcShipment.ShipmentName = "ShipmentName"; tdcShipment.ShipmentAddress.Line1 = "Line1"; tdcShipment.ShipmentAddress.PostCode = "NN8 1NB"; tdcShipment.SalesBranchCode = "BranchCode"; tdcShipment.AfterTime = "11:11"; tdcShipment.BeforeTime = "10:10"; tdcShipment.TailLiftRequired = false; tdcShipment.CheckInTime = 1; tdcShipment.DivisionCode = "Div"; tdcShipment.GeneratedDateTime = DateTime.Now; tdcShipment.Status = Shipment.StatusEnum.Mapped; tdcShipment.IsRecurring = false; tdcShipment.IsValidAddress = false; tdcShipment.PAFAddress.Line1 = "Line1"; tdcShipment.PAFAddress.PostCode = "PostCode"; tdcShipment.UpdatedBy = "UpdatedBy"; tdcShipment.Instructions = "Instructions"; tdcShipment.VehicleMaxWeight = (decimal)1.1; OpCoDivision division = OpcoDivisionTests.PopulateNewItem(); OpcoDivisionTests.SaveItem(division); tdcShipment.DivisionCode = division.Code; Warehouse deliveryWarehouse = WarehouseTests.PopulateNewItem(); WarehouseTests.SaveItem(deliveryWarehouse); tdcShipment.DeliveryWarehouseCode = deliveryWarehouse.Code; Warehouse stockWarehouse = WarehouseTests.PopulateNewItem(); WarehouseTests.SaveItem(stockWarehouse); tdcShipment.StockWarehouseCode = stockWarehouse.Code; Route route = RouteTests.PopulateNewItem(); RouteTests.SaveItem(route); tdcShipment.RouteCode = route.Code; TransactionType transactionType = TransactionTypeTests.PopulateNewItem(); TransactionTypeTests.SaveItem(transactionType); tdcShipment.TransactionTypeCode = transactionType.Code; TransactionSubType transactionSubType = TransactionSubTypeTests.PopulateNewItem(); TransactionSubTypeTests.SaveItem(transactionSubType); tdcShipment.TransactionSubTypeCode = transactionSubType.Code; return(tdcShipment); }