internal Trip PopulateNewItem() { Trip trip = new Trip(); trip.StartDate = DateTime.Today; trip.TripNumber = "12345678"; Warehouse warehouse = WarehouseTests.PopulateNewItem(); trip.WarehouseId = WarehouseController.SaveWarehouse(warehouse); trip.LeaveTime = DateTime.Now.ToShortTimeString(); trip.FinishTime = DateTime.Now.AddMinutes(10).ToShortTimeString(); trip.PeakWeight = 1; trip.PeakVolume = 2; trip.MaximumLoadWeight = 1; trip.MaximumLoadVolume = 2; trip.VehicleCost = 99; trip.RegionId = warehouse.RegionId; trip.VehicleRegistration = "NN56 TDC"; trip.AssignedDriver = "TDC AssignedDriver"; trip.TotalDistance = 100; //trip.LoadingTime = 20; //trip.TravellingTime = 30; //trip.WaitingTime = 40; trip.UpdatedBy = "TDC Team"; return(trip); }
/// <summary> /// Populates the new item. /// </summary> /// <returns></returns> internal NonWorkingDay PopulateNewItem() { NonWorkingDay nonWorkingDay = new NonWorkingDay(); nonWorkingDay.NonWorkingDate = DateTime.Today; nonWorkingDay.Description = DateTime.Today.DayOfWeek.ToString(); nonWorkingDay.UpdatedDate = DateTime.Today; nonWorkingDay.UpdatedBy = "TDC Team"; Warehouse warehouse = WarehouseTests.PopulateNewItem(); nonWorkingDay.WarehouseCode = warehouse.Code; nonWorkingDay.WarehouseId = WarehouseController.SaveWarehouse(warehouse); return(nonWorkingDay); }
public void GetItems() { using (TransactionScope scope = new TransactionScope()) { //add a warehouse int id = WarehouseController.SaveWarehouse(PopulateNewItem()); if (id > -1) { //retrieve all warehouses and the one we saved should return at least List <Warehouse> warehouses = WarehouseController.GetWarehouses(); //so the count should be >0 Assert.IsTrue(warehouses.Count > 0); //check for our new id Assert.IsTrue(warehouses.Find(delegate(Warehouse 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); } } } }
static internal int SaveItem(Warehouse Warehouse) { return(WarehouseController.SaveWarehouse(Warehouse)); }