Beispiel #1
0
        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");
        }
Beispiel #2
0
        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");
        }