public static void IsGreater(this ExpectationBuilder <int> builder, int expected)
 {
     if (builder.Value <= expected ^ builder.IsNegated)
     {
         throw new ExpectationFailedException($"Expected {(builder.IsNegated ? "not " : "")}to receive value greater than \"{expected}\", received \"{builder.Value}\" which is less or equal");
     }
 }
Exemplo n.º 2
0
        public static ExpectationBuilderProperties <T> PropertiesWithout <T>(this ExpectationBuilder <T> builder, params Expression <Func <T, object> >[] selectors)
        {
            var excludedProperties = selectors
                                     .Select(selector => PropertyUtils.ExtractProperty(selector))
                                     .Select(property => property.Name)
                                     .ToArray();

            return(new ExpectationBuilderProperties <T>(builder, excludedProperties));
        }
        public static void RaiseError(this ExpectationBuilder <Action> builder)
        {
            bool result;

            try
            {
                builder.Value.Invoke();
                result = false;
            }
            catch
            {
                result = true;
            }

            if (!result ^ builder.IsNegated)
            {
                throw new ExpectationFailedException($"Expected action {(builder.IsNegated ? "not " : "")}to fail");
            }
        }
 internal ExpectationBuilderProperties(ExpectationBuilder <T> builder, string[] excludedProperties)
     : base(builder.Value)
 {
     _innerBuilder      = builder;
     ExcludedProperties = excludedProperties;
 }
 internal ExpectationBuilderProperties(ExpectationBuilder <T> builder)
     : this(builder, Array.Empty <string>())
 {
 }
Exemplo n.º 6
0
 public static ExpectationBuilder <T> Not <T>(this ExpectationBuilder <T> builder)
 {
     return(new ExpectationBuilderNegated <T>(builder));
 }
Exemplo n.º 7
0
 public static ExpectationBuilderProperties <T> Properties <T>(this ExpectationBuilder <T> builder)
 {
     return(new ExpectationBuilderProperties <T>(builder));
 }