コード例 #1
0
 public static void Type(
     this WithType wt,
     Type expected)
 {
     Expect(wt.PropertyInfo.PropertyType)
     .To.Equal(expected,
               () => $"Expected {wt.ParentType}.{wt.PropertyInfo.Name} to have type {expected}");
 }
コード例 #2
0
        public static WithType Property(
            this IHave <Type> have,
            string name)
        {
            var result = new WithType();

            have.AddMatcher(actual =>
            {
                result.ParentType   = actual;
                result.PropertyInfo = actual.GetProperties(
                    BindingFlags.Public | BindingFlags.Instance
                    )
                                      .FirstOrDefault(pi => pi.Name == name);
                var passed = result.PropertyInfo != null;
                return(new MatcherResult(
                           passed,
                           () => $"Expected {actual} {passed.AsNot()}to have property '{name}'"
                           ));
            });
            return(result);
        }