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)); } }
public void GetItem_FullPopulate() { using (TransactionScope ts = new TransactionScope()) { TrunkerDay trunkerDay = PopulateNewItem(); trunkerDay.Id = SaveItem(trunkerDay); if (trunkerDay.Id != -1) { Assert.IsNotNull(TrunkerDaysController.GetTrunkerDay(trunkerDay.Id, true).DestinationWarehouse); } } }
public void GetItem() { using (TransactionScope ts = new TransactionScope()) { TrunkerDay trunkerDay = PopulateNewItem(); trunkerDay.Id = SaveItem(trunkerDay); if (trunkerDay.Id != -1) { Assert.IsNotNull(TrunkerDaysController.GetTrunkerDay(trunkerDay.Id, false)); } } }
public void GetItems() { using (TransactionScope scope = new TransactionScope()) { //add a trunker day int id = TrunkerDaysController.SaveTrunkerDay(PopulateNewItem()); if (id > -1) { //retrieve all trunker days and the one we saved should return at least List <TrunkerDay> trunkerDays = TrunkerDaysController.GetTrunkerDays(false); //so the count should be >0 Assert.IsTrue(trunkerDays.Count > 0); //check for our new id Assert.IsTrue(trunkerDays.Find(delegate(TrunkerDay currentItem) { return(currentItem.Id == id); }) != null); } } }
public void GetItems_CheckSort() { using (TransactionScope scope = new TransactionScope()) { //add a trunker day with a high number of days TrunkerDay trunkerDay = PopulateNewItem(); trunkerDay.Days = 10; int id = TrunkerDaysController.SaveTrunkerDay(trunkerDay); if (id > -1) { //add a trunker day with a lower number of days trunkerDay = trunkerDay.DeepClone <TrunkerDay>(); trunkerDay.Id = -1; trunkerDay.DestinationWarehouse = WarehouseTests.PopulateNewItem(); trunkerDay.DestinationWarehouse.Id = WarehouseController.SaveWarehouse(trunkerDay.DestinationWarehouse); trunkerDay.DestinationWarehouseId = trunkerDay.DestinationWarehouse.Id; trunkerDay.Days = 5; int id2 = TrunkerDaysController.SaveTrunkerDay(trunkerDay); if (id2 > -1) { //retrieve all trunker days and the one we saved should return at least List <TrunkerDay> trunkerDays = TrunkerDaysController.GetTrunkerDays(false, "Days"); //so the count should be >0 Assert.IsTrue(trunkerDays.Count > 0); //find the two we added trunkerDays = trunkerDays.FindAll(delegate(TrunkerDay currentItem) { return(currentItem.Id == id || currentItem.Id == id2); }); Assert.IsTrue(trunkerDays.Count == 2); Assert.IsTrue(trunkerDays[0].Days < trunkerDays[1].Days); } } } }
internal bool DeleteItem(TrunkerDay trunkerDay) { return(TrunkerDaysController.DeleteTrunkerDay(trunkerDay)); }
internal int SaveItem(TrunkerDay trunkerDay) { return(TrunkerDaysController.SaveTrunkerDay(trunkerDay)); }