Example #1
0
        public void YesFail()
        {
            Csla.ApplicationContext.GlobalContext.Clear();
            RollbackRoot root = Csla.Test.RollBack.RollbackRoot.NewRoot();

            root.BeginEdit();
            root.Data = "saved";
            root.Fail = true;
            Assert.AreEqual("saved", root.Data, "data is 'saved'");
            Assert.AreEqual(true, root.Fail, "fail is true");
            Assert.AreEqual(true, root.IsDirty, "isdirty is true");
            Assert.AreEqual(true, root.IsValid, "isvalid is true");
            Assert.AreEqual(true, root.IsNew, "isnew is true");

            Csla.ApplicationContext.GlobalContext.Clear();
            RollbackRoot tmp = (RollbackRoot)(root.Clone());

            try
            {
                root.ApplyEdit();
                root = (RollbackRoot)(root.Save());
                Assert.Fail("exception didn't occur");
            }
            catch
            {
                root = tmp;
            }

            Assert.IsNotNull(root, "obj is not null");
            Assert.AreEqual("Inserted", Csla.ApplicationContext.GlobalContext["Root"], "obj was inserted");
            Assert.AreEqual("saved", root.Data, "data is 'saved'");
            Assert.AreEqual(true, root.IsNew, "isnew is true");
            Assert.AreEqual(false, root.IsDeleted, "isdeleted is false");
            Assert.AreEqual(true, root.IsDirty, "isdirty is true");
        }
Example #2
0
        public void NoFail()
        {
            IDataPortal <RollbackRoot> dataPortal = _testDIContext.CreateDataPortal <RollbackRoot>();

            TestResults.Reinitialise();
            RollbackRoot root = Csla.Test.RollBack.RollbackRoot.NewRoot(dataPortal);

            root.BeginEdit();
            root.Data = "saved";
            Assert.AreEqual("saved", root.Data, "data is 'saved'");
            Assert.AreEqual(false, root.Fail, "fail is false");
            Assert.AreEqual(true, root.IsDirty, "isdirty is true");
            Assert.AreEqual(true, root.IsValid, "isvalid is true");
            Assert.AreEqual(true, root.IsNew, "isnew is true");

            TestResults.Reinitialise();
            RollbackRoot tmp = (RollbackRoot)(root.Clone());

            root.ApplyEdit();
            root = root.Save();

            Assert.IsNotNull(root, "obj is not null");
            Assert.AreEqual("Inserted", TestResults.GetResult("Root"), "obj was inserted");
            Assert.AreEqual("saved", root.Data, "data is 'saved'");
            Assert.AreEqual(false, root.IsNew, "is new is false");
            Assert.AreEqual(false, root.IsDeleted, "isdeleted is false");
            Assert.AreEqual(false, root.IsDirty, "isdirty is false");
        }