Example #1
0
        public void DCEditLevels()
        {
            IDataPortal <DCRoot> dataPortal = _testDIContext.CreateDataPortal <DCRoot>();

            DCRoot root = DCRoot.NewDCRoot(dataPortal);

            root.BeginEdit();
            root.Data = 123;
            root.CancelEdit();

            Assert.AreEqual(0, root.Data, "Data should be 0");

            root.BeginEdit();
            root.Data = 123;
            root.ApplyEdit();

            Assert.AreEqual(123, root.Data, "Data should be 123");
        }
Example #2
0
        public void DCClone()
        {
            IDataPortal <DCRoot> dataPortal = _testDIContext.CreateDataPortal <DCRoot>();

            System.Configuration.ConfigurationManager.AppSettings["CslaSerializationFormatter"] =
                "NetDataContractSerializer";
            // TODO: NDCS has been dropped I think; is there a way to replicate this test with another formatter?
            //Assert.AreEqual(
            //  Csla.ApplicationContext.SerializationFormatters.NetDataContractSerializer,
            //  Csla.ApplicationContext.SerializationFormatter,
            //  "Formatter should be NetDataContractSerializer");

            DCRoot root = DCRoot.NewDCRoot(dataPortal);

            root.Data = 123;
            DCRoot clone = root.Clone();

            Assert.IsFalse(ReferenceEquals(root, clone), "Object instance should be different");
            Assert.AreEqual(root.Data, clone.Data, "Data should match");
            Assert.IsTrue(root.IsDirty, "Root IsDirty should be true");
            Assert.IsTrue(clone.IsDirty, "Clone IsDirty should be true");
        }