private static IResponse AssertContentMatches <T>(this IHas @this, Func <HttpContent, T> selector, Func <T, bool> predicate)
        {
            return(@this.Assert(response =>
            {
                AssertContentExists(response);

                var value = selector(response.Content);

                if (!predicate(value))
                {
                    throw new OmicronException("Expected content to match");
                }
            }));
        }
        private static IResponse AssertHeaderMatches <T>(this IHas @this, string name, Func <HttpResponseHeaders, T> selector, Func <T, bool> predicate)
        {
            return(@this.Assert(response =>
            {
                AssertHeaderExists(name)(response);

                var value = selector(response.Headers);

                if (!predicate(value))
                {
                    throw new OmicronException($@"Expected header ""{name}"" to match");
                }
            }));
        }
 public static IResponse Header(this IHas @this, string name, Func <IEnumerable <string>, bool> predicate)
 => @this.Assert(AssertHeaderMatches(name, predicate));
 public static IResponse Xml(this IHas @this, Func <XDocument, bool> predicate)
 => @this.Assert(AssertContentMatches(predicate));
 public static IResponse Json <T>(this IHas @this, Func <T, bool> predicate)
 => @this.Assert(AssertContentMatches(predicate));
Esempio n. 6
0
 public static IResponse Status(this IHas @this, Func <int, bool> predicate)
 => @this.Assert(AssertStatusMatches(predicate));
Esempio n. 7
0
 public static IResponse Version(this IHas @this, Func <Version, bool> predicate)
 => @this.Assert(AssertVersionMatches(predicate));
 public static IResponse ReasonPhrase(this IHas @this, Func <string, bool> predicate)
 => @this.Assert(AssertReasonPhraseMatches(predicate));