Esempio n. 1
0
        public void Fail()
        {
            var expression = Expression(m =>
                                        m.Text == "test"
                    ? DryvResult.Error("fail")
                    : null);

            var jsProgram   = GetTranslatedAst(expression);
            var conditional = GetBodyExpression <ConditionalExpression>(jsProgram);
            var properties  = (conditional.Consequent as ObjectExpression)?.Properties;

            Assert.IsNotNull(properties);

            var first = (dynamic)properties.First().Value;

            Assert.AreEqual("error", first.Value);

            var second = (dynamic)properties.Last().Value;

            Assert.AreEqual("fail", second.Value);
        }
Esempio n. 2
0
 public static DryvRules Rules() => DryvRules
 .For <Model5>()
 .Rule(m => m.Text,
       m => m.Text != null
             ? DryvResult.Success
             : DryvResult.Error("error"));