コード例 #1
0
        public void MultipleAttributes()
        {
            var context = GetContext();

            var dp = new Csla.DataPortal <Multiple>();

            dp.CreateCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                    context.Assert.Fail(e.Error);
                }
                else
                {
                    var root  = e.Object;
                    var rules = root.GetRules();

                    Assert.AreEqual(3, rules.Length, "Should be 3 rules");
                    Assert.IsFalse(root.IsValid, "Obj shouldn't be valid");
                    Assert.AreEqual(1, root.BrokenRulesCollection.Count, "Should be 1 broken rule");
                    root.Name = "xyz";
                    Assert.AreEqual(2, root.BrokenRulesCollection.Count, "Should be 2 broken rules after edit");
                }
                context.Assert.Success();
            };
            dp.BeginCreate();

            context.Complete();
        }
コード例 #2
0
        public async Task CustomAttribute()
        {
            var context = GetContext();

            var dp   = new Csla.DataPortal <Custom>();
            var root = await dp.CreateAsync();

            var rules = root.GetRules();

            Assert.AreEqual(1, rules.Length, "Should be 1 rule");
            Assert.IsFalse(root.IsValid, "Obj shouldn't be valid");
            Assert.AreEqual(1, root.BrokenRulesCollection.Count, "Should be 1 broken rule");
            Assert.AreEqual("Name must be abc", root.BrokenRulesCollection[0].Description, "Desc should match");
            context.Assert.Success();

            context.Complete();
        }
コード例 #3
0
        public async Task MultipleAttributes()
        {
            var context = GetContext();

            var dp   = new Csla.DataPortal <Multiple>();
            var root = await dp.CreateAsync();

            var rules = root.GetRules();

            Assert.AreEqual(3, rules.Length, "Should be 3 rules");
            Assert.IsFalse(root.IsValid, "Obj shouldn't be valid");
            Assert.AreEqual(1, root.BrokenRulesCollection.Count, "Should be 1 broken rule");
            root.Name = "xyz";
            Assert.AreEqual(2, root.BrokenRulesCollection.Count, "Should be 2 broken rules after edit");
            context.Assert.Success();

            context.Complete();
        }
コード例 #4
0
        public void SingleAttribute()
        {
            var context = GetContext();

            var dp = new Csla.DataPortal <Single>();

            dp.CreateCompleted += (o, e) =>
            {
                var root  = e.Object;
                var rules = root.GetRules();

                Assert.AreEqual(1, rules.Length, "Should be 1 rule");
                Assert.IsFalse(root.IsValid, "Obj shouldn't be valid");
                Assert.AreEqual(1, root.BrokenRulesCollection.Count, "Should be 1 broken rule");
                Assert.AreEqual("Name value required", root.BrokenRulesCollection[0].Description, "Desc should match");
                context.Assert.Success();
            };
            dp.BeginCreate();

            context.Complete();
        }