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 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 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)); } }