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