예제 #1
0
 /// <summary>
 /// Asserts against an expected attribute, with a matcher for the attribute
 /// </summary>
 /// <param name="with"></param>
 /// <param name="matcher"></param>
 /// <param name="customMessageGenerator"></param>
 /// <typeparam name="TAttribute"></typeparam>
 /// <returns></returns>
 public static IMore <MethodInfo> Attribute <TAttribute>(
     this IWith <MethodInfo> with,
     Func <TAttribute, bool> matcher,
     Func <string> customMessageGenerator
     ) where TAttribute : Attribute
 {
     matcher ??= _ => true;
     return(with.AddMatcher(actual =>
                            TryMatchAnyParameterAttribute(actual, matcher, customMessageGenerator)
                            ?? TryMatchParameterAttribute(actual, matcher, customMessageGenerator)
                            ?? MatchMethodAttribute(actual, matcher, customMessageGenerator)
                            ));
 }
예제 #2
0
파일: With.cs 프로젝트: fluffynuts/NExpect
 public static IMore <Dog> Name(
     this IWith <Dog> with,
     string expected)
 {
     return(with.AddMatcher(actual =>
     {
         var name = actual.Name; // ?.GetOrDefault(nameof(Animal.Name), null as string);
         var passed = name == expected;
         return new MatcherResult(
             passed,
             () => $"Expected {actual} to have name '{expected}'"
             );
     }));
 }