public void UpdateItem() { _isListSaved = false; ERlist list = new ERlist(); list.Saved += new EventHandler <Csla.Core.SavedEventArgs>(List_Saved); list.Add(ERitem.GetItem("test")); ERitem item = list[0]; Assert.AreEqual(1, list.Count, "Incorrect count after add"); Assert.IsFalse(list[0].IsNew, "Object should not be new"); // simulate grid edit System.ComponentModel.IEditableObject obj = (System.ComponentModel.IEditableObject)item; obj.BeginEdit(); item.Data = "new data"; Assert.IsFalse(list[0].IsNew, "Object should not be new"); Assert.IsFalse(list[0].IsDeleted, "Object should not be deleted"); Assert.IsTrue(list[0].IsDirty, "Object should be dirty"); obj.EndEdit(); Assert.AreEqual(true, _isListSaved, "List saved event did not fire after save."); Assert.AreEqual("Update", ApplicationContext.GlobalContext["DP"].ToString(), "Object should have been updated"); Assert.IsFalse(list[0].IsNew, "Object should not be new"); }
public void UpdateItem() { IDataPortal <ERlist> dataPortal = _testDIContext.CreateDataPortal <ERlist>(); IDataPortal <ERitem> itemDataPortal = _testDIContext.CreateDataPortal <ERitem>(); TestResults.Reinitialise(); _isListSaved = false; ERlist list = dataPortal.Create(); list.Saved += new EventHandler <Csla.Core.SavedEventArgs>(List_Saved); list.Add(itemDataPortal.Fetch("test")); ERitem item = list[0]; Assert.AreEqual(1, list.Count, "Incorrect count after add"); Assert.IsFalse(list[0].IsNew, "Object should not be new"); // simulate grid edit System.ComponentModel.IEditableObject obj = (System.ComponentModel.IEditableObject)item; obj.BeginEdit(); item.Data = "new data"; Assert.IsFalse(list[0].IsNew, "Object should not be new"); Assert.IsFalse(list[0].IsDeleted, "Object should not be deleted"); Assert.IsTrue(list[0].IsDirty, "Object should be dirty"); obj.EndEdit(); Assert.AreEqual(true, _isListSaved, "List saved event did not fire after save."); Assert.AreEqual("Update", TestResults.GetResult("DP"), "Object should have been updated"); Assert.IsFalse(list[0].IsNew, "Object should not be new"); }
public void AddItem() { ERlist list = new ERlist(); ERitem item = list.AddNew(); Assert.AreEqual(1, list.Count, "Count should be 1"); Assert.IsTrue(list[0].IsNew, "Object should be new"); }
public void BusyImplemented() { IDataPortal <ERlist> dataPortal = _testDIContext.CreateDataPortal <ERlist>(); ERlist list = dataPortal.Create(); Assert.IsFalse(list.IsBusy); }
public void AddItem() { IDataPortal <ERlist> dataPortal = _testDIContext.CreateDataPortal <ERlist>(); ERlist list = dataPortal.Create(); ERitem item = list.AddNew(); Assert.AreEqual(1, list.Count, "Count should be 1"); Assert.IsTrue(list[0].IsNew, "Object should be new"); }
public void RemoveNewItem() { ApplicationContext.GlobalContext.Clear(); _isListSaved = false; ERlist list = new ERlist(); ERitem item = list.AddNew(); Assert.AreEqual(1, list.Count, "Incorrect count after add"); Assert.IsTrue(list[0].IsNew, "Object should be new"); list.Saved += new EventHandler <Csla.Core.SavedEventArgs>(List_Saved); list.RemoveAt(0); Assert.AreEqual(true, _isListSaved, "List saved event did not fire after save."); Assert.AreEqual(0, list.Count, "Incorrect count after remove"); Assert.IsNull(ApplicationContext.GlobalContext["DP"], "Object should not have done a delete"); Assert.IsTrue(item.IsNew, "Object should be new after delete"); }
public void ErrorRecoveryTest() { ERlist list = new ERlist(); bool errorOccurred = false; try { list.SaveItem(10); } catch (Exception ex) { errorOccurred = true; } Assert.AreEqual(true, errorOccurred, "An error should have been thrown."); Assert.AreEqual(true, list.RaiseListChangedEvents, "RaiseListChangedEvents should have been reset"); }
public void RemoveNewItem() { IDataPortal <ERlist> dataPortal = _testDIContext.CreateDataPortal <ERlist>(); TestResults.Reinitialise(); _isListSaved = false; ERlist list = dataPortal.Create(); ERitem item = list.AddNew(); Assert.AreEqual(1, list.Count, "Incorrect count after add"); Assert.IsTrue(list[0].IsNew, "Object should be new"); list.Saved += new EventHandler <Csla.Core.SavedEventArgs>(List_Saved); list.RemoveAt(0); Assert.AreEqual(true, _isListSaved, "List saved event did not fire after save."); Assert.AreEqual(0, list.Count, "Incorrect count after remove"); Assert.AreEqual("", TestResults.GetResult("DP"), "Object should not have done a delete"); Assert.IsTrue(item.IsNew, "Object should be new after delete"); }
public void ErrorRecoveryTest() { IDataPortal <ERlist> dataPortal = _testDIContext.CreateDataPortal <ERlist>(); ERlist list = dataPortal.Create(); bool errorOccurred = false; try { list.SaveItem(10); } catch { errorOccurred = true; } Assert.AreEqual(true, errorOccurred, "An error should have been thrown."); Assert.AreEqual(true, list.RaiseListChangedEvents, "RaiseListChangedEvents should have been reset"); }
public void RemoveOldItem() { ApplicationContext.GlobalContext.Clear(); _isListSaved = false; ERlist list = new ERlist(); list.Add(ERitem.GetItem("test")); ERitem item = list[0]; item.Saved += new EventHandler <Csla.Core.SavedEventArgs>(item_Saved); list.Saved += new EventHandler <Csla.Core.SavedEventArgs>(List_Saved); Assert.AreEqual(1, list.Count, "Incorrect count after add"); Assert.IsFalse(list[0].IsNew, "Object should not be new"); list.RemoveAt(0); Assert.AreEqual(true, _isListSaved, "List saved event did not fire after save."); Assert.AreEqual(0, list.Count, "Incorrect count after remove"); Assert.AreEqual("DeleteSelf", ApplicationContext.GlobalContext["DP"].ToString(), "Object should have deleted itself"); Assert.IsTrue(_itemIsNew, "Object should be new after delete"); }
public void BusyImplemented() { ERlist list = new ERlist(); Assert.IsFalse(list.IsBusy); }