public void Given_NullHeader_When_Headers_Invoked_Then_It_Should_Return_Result() { var context = new Mock <FunctionContext>(); var baseHost = "localhost"; var uri = Uri.TryCreate($"http://{baseHost}", UriKind.Absolute, out var tried) ? tried : null; var req = (HttpRequestData) new FakeHttpRequestData(context.Object, uri, headers: null); var result = OpenApiHttpRequestDataExtensions.Headers(req); result.Count.Should().Be(0); }
public void Given_Headers_When_Headers_Invoked_Then_It_Should_Return_Result(string headerstring, params string[] keys) { var context = new Mock <FunctionContext>(); var baseHost = "localhost"; var uri = Uri.TryCreate($"http://{baseHost}", UriKind.Absolute, out var tried) ? tried : null; var kvps = headerstring.Split('&').ToDictionary(p => p.Split('=').First(), p => p.Split('=').Last()); var headers = new Dictionary <string, string>(kvps); var req = (HttpRequestData) new FakeHttpRequestData(context.Object, uri, headers: headers); var result = OpenApiHttpRequestDataExtensions.Headers(req); result.Count.Should().Be(keys.Length); result.Keys.Should().Contain(keys); }
public void Given_Null_When_Headers_Invoked_Then_It_Should_Throw_Exception() { Action action = () => OpenApiHttpRequestDataExtensions.Headers(null); action.Should().Throw <ArgumentNullException>(); }