Beispiel #1
0
        public void Assert(Scenario scenario, HttpContext context, ScenarioAssertionException ex)
        {
            var headers = context.Response.Headers;

            if (headers.ContainsKey(_headerKey))
            {
                var values    = headers[_headerKey];
                var valueText = values.Select(x => "'" + x + "'").Join(", ");
                ex.Add($"Expected no value for header '{_headerKey}', but found values {valueText}");
            }
        }
        public void Assert(Scenario scenario, ScenarioAssertionException ex)
        {
            var values = scenario.Context.Response.Headers[_headerKey];

            switch (values.Count)
            {
            case 0:
                ex.Add(
                    $"Expected a single header value of '{_headerKey}', but no values were found on the response");
                break;

            case 1:
                // nothing, thats' good;)
                break;

            default:
                var valueText = values.Select(x => "'" + x + "'").Join(", ");
                ex.Add($"Expected a single header value of '{_headerKey}', but found multiple values on the response: {valueText}");
                break;
            }
        }