Пример #1
0
        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");
                }
            }));
        }
Пример #2
0
        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");
                }
            }));
        }
Пример #3
0
 public static IResponse Header(this IHas @this, string name, Func <IEnumerable <string>, bool> predicate)
 => @this.Assert(AssertHeaderMatches(name, predicate));
Пример #4
0
 public static IResponse Xml(this IHas @this, Func <XDocument, bool> predicate)
 => @this.Assert(AssertContentMatches(predicate));
Пример #5
0
 public static IResponse Json <T>(this IHas @this, Func <T, bool> predicate)
 => @this.Assert(AssertContentMatches(predicate));
Пример #6
0
 public static IResponse Status(this IHas @this, Func <int, bool> predicate)
 => @this.Assert(AssertStatusMatches(predicate));
Пример #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));