Exemplo n.º 1
0
        public void VerifyUndoableStateStackOnClone()
        {
            Csla.ApplicationContext.GlobalContext.Clear();
            using (UnitTestContext context = GetContext())
            {
                HasRulesManager2.NewHasRulesManager2((o, e) =>
                {
                    context.Assert.IsNull(e.Error);
                    HasRulesManager2 root = e.Object;

                    string expected = root.Name;
                    root.BeginEdit();
                    root.Name = "";
                    HasRulesManager2 rootClone = root.Clone();
                    rootClone.CancelEdit();

                    string actual = rootClone.Name;
                    context.Assert.AreEqual(expected, actual);
                    context.Assert.Try(rootClone.ApplyEdit);

                    context.Assert.Success();
                });
                context.Complete();
            }
        }
Exemplo n.º 2
0
        public void TestValidationRulesAfterClone()
        {
            //this test uses HasRulesManager2, which assigns criteria._name to its public
            //property in DataPortal_Create.  If it used HasRulesManager, it would fail
            //the first assert, but pass the others
            Csla.ApplicationContext.GlobalContext.Clear();
            UnitTestContext context = GetContext();

            HasRulesManager2.NewHasRulesManager2((o, e) =>
            {
                context.Assert.Try(() =>
                {
                    HasRulesManager2 root = e.Object;
                    context.Assert.AreEqual(true, root.IsValid);
                    root.BeginEdit();
                    root.Name = "";
                    root.ApplyEdit();

                    context.Assert.AreEqual(false, root.IsValid);
                    HasRulesManager2 rootClone = root.Clone();
                    context.Assert.AreEqual(false, rootClone.IsValid);

                    rootClone.Name = "something";
                    context.Assert.AreEqual(true, rootClone.IsValid);
                    context.Assert.Success();
                });
            });
            context.Complete();
        }
Exemplo n.º 3
0
        public async Task VerifyUndoableStateStackOnClone()
        {
            TestResults.Reinitialise();
            using (UnitTestContext context = GetContext())
            {
                var root = await CreateHasRulesManager2Async();

                string expected = root.Name;
                root.BeginEdit();
                root.Name = "";
                HasRulesManager2 rootClone = root.Clone();
                rootClone.CancelEdit();

                string actual = rootClone.Name;
                context.Assert.AreEqual(expected, actual);
                context.Assert.Try(rootClone.ApplyEdit);

                context.Assert.Success();
                context.Complete();
            }
        }
Exemplo n.º 4
0
        public async Task TestValidationRulesAfterClone()
        {
            //this test uses HasRulesManager2, which assigns criteria._name to its public
            //property in DataPortal_Create.  If it used HasRulesManager, it would fail
            //the first assert, but pass the others
            TestResults.Reinitialise();
            var root = await CreateHasRulesManager2Async("test");

            Assert.AreEqual(true, root.IsValid);
            root.BeginEdit();
            root.Name = "";
            root.ApplyEdit();

            Assert.AreEqual(false, root.IsValid);
            HasRulesManager2 rootClone = root.Clone();

            Assert.AreEqual(false, rootClone.IsValid);

            rootClone.Name = "something";
            Assert.AreEqual(true, rootClone.IsValid);
        }
Exemplo n.º 5
0
        public async Task VerifyUndoableStateStackOnClone()
        {
            Csla.ApplicationContext.GlobalContext.Clear();
            using (UnitTestContext context = GetContext())
            {
                var root = await Csla.DataPortal.CreateAsync <HasRulesManager2>();

                string expected = root.Name;
                root.BeginEdit();
                root.Name = "";
                HasRulesManager2 rootClone = root.Clone();
                rootClone.CancelEdit();

                string actual = rootClone.Name;
                context.Assert.AreEqual(expected, actual);
                context.Assert.Try(rootClone.ApplyEdit);

                context.Assert.Success();
                context.Complete();
            }
        }
Exemplo n.º 6
0
        public async Task TestValidationRulesAfterClone()
        {
            //this test uses HasRulesManager2, which assigns criteria._name to its public
            //property in DataPortal_Create.  If it used HasRulesManager, it would fail
            //the first assert, but pass the others
            Csla.ApplicationContext.GlobalContext.Clear();
            var root = await Csla.DataPortal.CreateAsync <HasRulesManager2>(new HasRulesManager2.Criteria("test"));

            Assert.AreEqual(true, root.IsValid);
            root.BeginEdit();
            root.Name = "";
            root.ApplyEdit();

            Assert.AreEqual(false, root.IsValid);
            HasRulesManager2 rootClone = root.Clone();

            Assert.AreEqual(false, rootClone.IsValid);

            rootClone.Name = "something";
            Assert.AreEqual(true, rootClone.IsValid);
        }
Exemplo n.º 7
0
        public void TestValidationRulesWithPublicProperty()
        {
            UnitTestContext context = GetContext();

            //should work since ValidationRules.CheckRules() is called in DataPortal_Create
            Csla.ApplicationContext.GlobalContext.Clear();
            HasRulesManager2.NewHasRulesManager2((o, e) =>
            {
                HasRulesManager2 root = e.Object;
                context.Assert.AreEqual("<new>", root.Name);
                context.Assert.AreEqual(true, root.IsValid, "should be valid on create");
                context.Assert.AreEqual(0, root.BrokenRulesCollection.Count);

                root.BeginEdit();
                root.Name = "";
                root.CancelEdit();

                context.Assert.AreEqual("<new>", root.Name);
                context.Assert.AreEqual(true, root.IsValid, "should be valid after CancelEdit");
                context.Assert.AreEqual(0, root.BrokenRulesCollection.Count);

                root.BeginEdit();
                root.Name = "";
                root.ApplyEdit();

                context.Assert.AreEqual("", root.Name);
                context.Assert.AreEqual(false, root.IsValid);
                context.Assert.AreEqual(1, root.BrokenRulesCollection.Count);
                context.Assert.AreEqual("Name required", root.BrokenRulesCollection[0].Description);
                context.Assert.AreEqual("Name required", root.BrokenRulesCollection.GetFirstMessage(HasRulesManager2.NameProperty).Description);
                context.Assert.AreEqual("Name required", root.BrokenRulesCollection.GetFirstBrokenRule(HasRulesManager2.NameProperty).Description);
                context.Assert.Success();
            });

            context.Complete();
        }