Beispiel #1
0
        internal CheckMember(ICheck <T> originalCheck, Expression <Func <T, TM> > extractor, string name)
        {
            var syntaxHelper = (FluentSut <T>)originalCheck;

            this.originalCheck = originalCheck;
            var sub = syntaxHelper.Extract(sut => extractor.Compile().Invoke(sut),
                                           x => $"{x.SutName.EntityName}'s {name}", this);

            this.fluentCheck = new FluentCheck <TM>(sub, false)
            {
                CustomMessage = syntaxHelper.CustomMessage
            };
        }
Beispiel #2
0
        /// <summary>
        /// Allows to check some property of the raised exception
        /// </summary>
        /// <typeparam name="T">Exception type</typeparam>
        /// <typeparam name="TM">Property/field type</typeparam>
        /// <param name="checker">Syntax helper</param>
        /// <param name="propertyExpression">Extracting expression.</param>
        /// <returns>A checker object for the property value</returns>
        public static ICheck <TM> WhichMember <T, TM>(this ILambdaExceptionCheck <T> checker, Expression <Func <T, TM> > propertyExpression)
            where T : Exception
        {
            var syntaxHelper = (FluentSut <T>)checker;
            var name         = GetPropertyNameFromExpression(propertyExpression);
            var sub          = syntaxHelper.Extract(propertyExpression.Compile(),
                                                    value => $"{value.SutName.EntityName}'s {name}");
            var res = new FluentCheck <TM>(sub, syntaxHelper.Negated)
            {
                CustomMessage = syntaxHelper.CustomMessage
            };

            return(res);
        }