Esempio n. 1
0
        public void FormRuleExecuteTest()
        {
            var form   = new TestForm3();
            var fields = ((IDynamicEditForm)form).GetFields();

            Assert.Equal(5, fields.Count());

            var nameField = fields.First(f => f.BindingProperty == "ClientName");

            Assert.Single(nameField.Rules);

            var order = new Order {
                ClientName = "Bashirov"
            };
            var result = nameField.Rules[0].Method(order);

            Assert.Null(result);
        }
Esempio n. 2
0
        public void FormRuleErrorTest()
        {
            var form   = new TestForm3();
            var fields = ((IDynamicEditForm)form).GetFields();

            Assert.Equal(5, fields.Count());

            var nameField = fields.First(f => f.BindingProperty == "ClientName");

            Assert.Single(nameField.Rules);

            var order = new Order {
                ClientName = "Petrov"
            };
            var result = nameField.Rules[0].Method(order);

            Assert.True(result.IsFailed);
            Assert.Equal("wrong name", result.Message);
            Assert.Equal("CheckName", result.RuleName);
        }