Пример #1
0
        public static ValidationPair <TSource> AssertProperty <TSource, TProperty>(
            this ValidationPair <TSource> source,
            ValidationResultType resultType,
            Expression <Func <TSource, TProperty> > exp)
            where TSource : DefinitionBase
        {
            var result = source.ValidationResult;
            var prop   = ReflectionUtils.GetExpressionValue(source.Model, exp);

            Assert.IsTrue(
                result.Count(r => r.PropertyName == prop.Name &&
                             !r.IsValid &&
                             r.ResultType == resultType) > 0);

            return(source);
        }
Пример #2
0
        public static ValidationPair <TSource> AssertProperty <TSource, TProperty>(
            this ValidationPair <TSource> source,
            ValidationResultType resultType,
            Expression <Func <TSource, TProperty> > exp)
            where TSource : DefinitionBase
        {
            var result = source.ValidationResult;
            var prop   = ReflectionUtils.GetExpressionValue(source.Model, exp);

            IndentableTrace.WithScope(s =>
            {
                s.WriteLine(string.Format("Validating property: [{0}]", prop.Name));

                Assert.IsTrue(result.Count(r => r.PropertyName == prop.Name &&
                                           !r.IsValid &&
                                           r.ResultType == resultType) > 0);
            });

            return(source);
        }