diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f6cc35e0..dc7f4472 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -25,10 +25,8 @@ env: DOTNET_NOLOGO: true dotnet-version: | 8.0.x + 7.0.x 6.0.x - 5.0.x - 3.1.x - 2.1.x jobs: analyze: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a99af4aa..cf06e561 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,10 +13,8 @@ env: DOTNET_NOLOGO: true dotnet-version: | 8.0.x + 7.0.x 6.0.x - 5.0.x - 3.1.x - 2.1.x jobs: determine-version: diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index c39bbe8e..9967ecbe 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -14,10 +14,8 @@ env: DOTNET_NOLOGO: true dotnet-version: | 8.0.x + 7.0.x 6.0.x - 5.0.x - 3.1.x - 2.1.x jobs: # Blog https://iterative.ai/blog/testing-external-contributions-using-github-actions-secrets diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets index fb66ddc0..50336272 100644 --- a/test/Directory.Build.targets +++ b/test/Directory.Build.targets @@ -7,6 +7,8 @@ 17.11.1 true + true + $(DefineConstants);TEST_NETSTANDARD2_0 true $(DefineConstants);TEST_NETSTANDARD2_1 diff --git a/test/MockHttp.Json.Tests/MockHttp.Json.Tests.csproj b/test/MockHttp.Json.Tests/MockHttp.Json.Tests.csproj index fb32704b..6aa238f0 100644 --- a/test/MockHttp.Json.Tests/MockHttp.Json.Tests.csproj +++ b/test/MockHttp.Json.Tests/MockHttp.Json.Tests.csproj @@ -1,7 +1,7 @@  - net8.0;net7.0;net6.0;net5.0;netcoreapp2.1;net48;net472;net462 + net8.0;net7.0;net6.0;net481;net48;net472;net462 true @@ -15,9 +15,9 @@ - + + - \ No newline at end of file diff --git a/test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.0_via_.NET_Core_2.1.verified.txt b/test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.0_via_.NET_Framework_4.8.1.verified.txt similarity index 100% rename from test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.0_via_.NET_Core_2.1.verified.txt rename to test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.0_via_.NET_Framework_4.8.1.verified.txt diff --git a/test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.1_via_.NET_5.0.verified.txt b/test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.1_via_.NET_5.0.verified.txt deleted file mode 100644 index 0cf2ac41..00000000 --- a/test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.1_via_.NET_5.0.verified.txt +++ /dev/null @@ -1,65 +0,0 @@ -[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/MockHttp")] -[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName=".NET Standard 2.1")] -namespace MockHttp.Json -{ - public interface IJsonAdapter - { - string Serialize(object? value); - } - public static class JsonRequestMatchingExtensions - { - public static MockHttp.RequestMatching JsonBody(this MockHttp.RequestMatching builder, T content) { } - public static MockHttp.RequestMatching JsonBody(this MockHttp.RequestMatching builder, T body, MockHttp.Json.IJsonAdapter? adapter) { } - } - public static class MockConfigurationExtensions - { - public static MockHttp.IMockConfiguration UseJsonAdapter(this MockHttp.IMockConfiguration mockConfig, MockHttp.Json.IJsonAdapter jsonAdapter) { } - } - public static class ResponseBuilderExtensions - { - public static MockHttp.Language.Flow.Response.IWithContentResult JsonBody(this MockHttp.Language.Response.IWithContent builder, System.Func jsonContentFactory, System.Text.Encoding? encoding = null, MockHttp.Json.IJsonAdapter? adapter = null) { } - public static MockHttp.Language.Flow.Response.IWithContentResult JsonBody(this MockHttp.Language.Response.IWithContent builder, T jsonContent, System.Text.Encoding? encoding = null, MockHttp.Json.IJsonAdapter? adapter = null) { } - } -} -namespace MockHttp.Json.Newtonsoft -{ - public static class MockConfigurationExtensions - { - public static MockHttp.IMockConfiguration UseNewtonsoftJson(this MockHttp.IMockConfiguration mockConfig, Newtonsoft.Json.JsonSerializerSettings? serializerSettings = null) { } - } - public class NewtonsoftAdapter : MockHttp.Json.IJsonAdapter - { - public NewtonsoftAdapter(Newtonsoft.Json.JsonSerializerSettings? settings = null) { } - public string Serialize(object? value) { } - } - public static class RequestMatchingExtensions - { - public static MockHttp.RequestMatching JsonBody(this MockHttp.RequestMatching builder, T body, Newtonsoft.Json.JsonSerializerSettings? serializerSettings) { } - } - public static class ResponseBuilderExtensions - { - public static MockHttp.Language.Flow.Response.IWithContentResult JsonBody(this MockHttp.Language.Response.IWithContent builder, System.Func jsonContentFactory, System.Text.Encoding? encoding = null, Newtonsoft.Json.JsonSerializerSettings? serializerSettings = null) { } - public static MockHttp.Language.Flow.Response.IWithContentResult JsonBody(this MockHttp.Language.Response.IWithContent builder, T jsonContent, System.Text.Encoding? encoding = null, Newtonsoft.Json.JsonSerializerSettings? serializerSettings = null) { } - } -} -namespace MockHttp.Json.SystemTextJson -{ - public static class MockConfigurationExtensions - { - public static MockHttp.IMockConfiguration UseSystemTextJson(this MockHttp.IMockConfiguration mockConfig, System.Text.Json.JsonSerializerOptions? options = null) { } - } - public static class RequestMatchingExtensions - { - public static MockHttp.RequestMatching JsonBody(this MockHttp.RequestMatching builder, T body, System.Text.Json.JsonSerializerOptions? serializerOptions) { } - } - public static class ResponseBuilderExtensions - { - public static MockHttp.Language.Flow.Response.IWithContentResult JsonBody(this MockHttp.Language.Response.IWithContent builder, System.Func jsonContentFactory, System.Text.Encoding? encoding = null, System.Text.Json.JsonSerializerOptions? serializerOptions = null) { } - public static MockHttp.Language.Flow.Response.IWithContentResult JsonBody(this MockHttp.Language.Response.IWithContent builder, T jsonContent, System.Text.Encoding? encoding = null, System.Text.Json.JsonSerializerOptions? serializerOptions = null) { } - } - public sealed class SystemTextJsonAdapter : MockHttp.Json.IJsonAdapter - { - public SystemTextJsonAdapter(System.Text.Json.JsonSerializerOptions? options = null) { } - public string Serialize(object? value) { } - } -} \ No newline at end of file diff --git a/test/MockHttp.Testing/MockHttp.Testing.csproj b/test/MockHttp.Testing/MockHttp.Testing.csproj index f3fb2b26..b808fdd3 100644 --- a/test/MockHttp.Testing/MockHttp.Testing.csproj +++ b/test/MockHttp.Testing/MockHttp.Testing.csproj @@ -1,15 +1,14 @@  - net8.0;net7.0;net6.0;net5.0;netcoreapp2.1;net48;net472;net462 + net8.0;net7.0;net6.0;net481;;net48;net472;net462 false MockHttp 26.6.0 - 20.8.2 - 18.1.0 + 20.8.2 true $(DefineConstants);VERIFY_PUBLIC_API @@ -26,7 +25,8 @@ - + + diff --git a/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs b/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs index 0f88e407..c48a0293 100644 --- a/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs +++ b/test/MockHttp.Tests/Internal/Response/Behaviors/TimeoutBehaviorTests.cs @@ -19,12 +19,17 @@ public async Task Given_that_timeout_is_not_zero_when_sending_it_should_timeout_ ResponseHandlerDelegate nextStub = Substitute.For(); // Act - Func act = () => sut.HandleAsync(new MockHttpRequestContext(new HttpRequestMessage()), new HttpResponseMessage(), nextStub, CancellationToken.None); + Func act = () => sut.HandleAsync( + new MockHttpRequestContext(new HttpRequestMessage()), + new HttpResponseMessage(), + nextStub, + CancellationToken.None + ); // Assert sw.Start(); -#if NET5_0_OR_GREATER +#if TEST_NETSTANDARD2_1 || NET6_0_OR_GREATER await act.Should().ThrowAsync().WithInnerException(typeof(TimeoutException), "the timeout expired"); #else await act.Should().ThrowAsync("the timeout expired"); diff --git a/test/MockHttp.Tests/MockHttp.Tests.csproj b/test/MockHttp.Tests/MockHttp.Tests.csproj index b7c51a88..1f751dac 100644 --- a/test/MockHttp.Tests/MockHttp.Tests.csproj +++ b/test/MockHttp.Tests/MockHttp.Tests.csproj @@ -1,7 +1,7 @@  - net8.0;net7.0;net6.0;net5.0;netcoreapp2.1;net48;net472;net462 + net8.0;net7.0;net6.0;net481;net48;net472;net462 true @@ -15,7 +15,8 @@ - + + diff --git a/test/MockHttp.Tests/MockHttpHandlerTests.cs b/test/MockHttp.Tests/MockHttpHandlerTests.cs index bef966b0..d2f0baab 100644 --- a/test/MockHttp.Tests/MockHttpHandlerTests.cs +++ b/test/MockHttp.Tests/MockHttpHandlerTests.cs @@ -336,15 +336,29 @@ public async Task Given_a_request_expectation_when_sending_requests_it_should_co Field3 = DateTime.UtcNow }; string jsonPostContent = JsonConvert.SerializeObject(postObject); - var lastModified = new DateTime(2018, 4, 12, 7, 22, 43, DateTimeKind.Local); - var postContent = new StringContent(jsonPostContent, Encoding.UTF8, MediaTypes.Json) { Headers = { LastModified = lastModified } }; + var lastModified = new DateTime( + 2018, + 4, + 12, + 7, + 22, + 43, + DateTimeKind.Local + ); + var postContent = new StringContent(jsonPostContent, Encoding.UTF8, MediaTypes.Json) + { + Headers = + { + LastModified = lastModified + } + }; // ReSharper disable once JoinDeclarationAndInitializer Version version; -#if NETCOREAPP3_1 || NET6_0_OR_GREATER +#if NET6_0_OR_GREATER version = _httpClient.DefaultRequestVersion; #else -#if NET5_0_OR_GREATER +#if TEST_NETSTANDARD2_1 || NET6_0_OR_GREATER version = new Version(2, 0); #else version = new Version(1, 1); @@ -352,32 +366,45 @@ public async Task Given_a_request_expectation_when_sending_requests_it_should_co #endif _sut - .When(matching => matching - .RequestUri("http://0.0.0.1/*/action*") - .QueryString("test", "$%^&*") - .QueryString("test2=value") - .Method("POST") - .Body(jsonPostContent) - .PartialBody(jsonPostContent.Substring(10)) - .ContentType($"{MediaTypes.Json}; charset=utf-8") - .BearerToken() - .Header("Content-Length", jsonPostContent.Length) - .Header("Last-Modified", lastModified) - .Version(version) - .Any(any => any - .RequestUri("not-matching") - .RequestUri("**controller**") - ) - .Where(r => 0 < r.Version.Major) + .When( + matching => matching + .RequestUri("http://0.0.0.1/*/action*") + .QueryString("test", "$%^&*") + .QueryString("test2=value") + .Method("POST") + .Body(jsonPostContent) + .PartialBody(jsonPostContent.Substring(10)) + .ContentType($"{MediaTypes.Json}; charset=utf-8") + .BearerToken() + .Header("Content-Length", jsonPostContent.Length) + .Header("Last-Modified", lastModified) + .Version(version) + .Any( + any => any + .RequestUri("not-matching") + .RequestUri("**controller**") + ) + .Where(r => 0 < r.Version.Major) ) - .Callback(() => - { - }) - .Respond(with => with - .StatusCode(HttpStatusCode.Accepted) - .Body(JsonConvert.SerializeObject(new { firstName = "John", lastName = "Doe" })) - .TransferRate(BitRate.TwoG) - .Latency(NetworkLatency.TwoG) + .Callback( + () => + { + } + ) + .Respond( + with => with + .StatusCode(HttpStatusCode.Accepted) + .Body( + JsonConvert.SerializeObject( + new + { + firstName = "John", + lastName = "Doe" + } + ) + ) + .TransferRate(BitRate.TwoG) + .Latency(NetworkLatency.TwoG) ) .Verifiable(); @@ -385,7 +412,10 @@ public async Task Given_a_request_expectation_when_sending_requests_it_should_co await _httpClient.GetAsync("http://0.0.0.1/controller/action?test=1"); var req = new HttpRequestMessage(HttpMethod.Post, "http://0.0.0.1/controller/action?test=%24%25^%26*&test2=value") { - Headers = { Authorization = new AuthenticationHeaderValue("Bearer", "some-token") }, + Headers = + { + Authorization = new AuthenticationHeaderValue("Bearer", "some-token") + }, Content = postContent, Version = version }; @@ -401,8 +431,14 @@ public async Task Given_a_request_expectation_when_sending_requests_it_should_co await response.Should() .HaveStatusCode(HttpStatusCode.Accepted) - .And.HaveContentAsync(JsonConvert.SerializeObject( - new { firstName = "John", lastName = "Doe" }) + .And.HaveContentAsync( + JsonConvert.SerializeObject( + new + { + firstName = "John", + lastName = "Doe" + } + ) ); } diff --git a/test/MockHttp.Tests/PublicApi/.NET_Standard_2.0_via_.NET_Core_2.1.verified.txt b/test/MockHttp.Tests/PublicApi/.NET_Standard_2.0_via_.NET_Framework_4.8.1.verified.txt similarity index 100% rename from test/MockHttp.Tests/PublicApi/.NET_Standard_2.0_via_.NET_Core_2.1.verified.txt rename to test/MockHttp.Tests/PublicApi/.NET_Standard_2.0_via_.NET_Framework_4.8.1.verified.txt diff --git a/test/MockHttp.Tests/PublicApi/.NET_Standard_2.1_via_.NET_5.0.verified.txt b/test/MockHttp.Tests/PublicApi/.NET_Standard_2.1_via_.NET_5.0.verified.txt deleted file mode 100644 index 407b85cf..00000000 --- a/test/MockHttp.Tests/PublicApi/.NET_Standard_2.1_via_.NET_5.0.verified.txt +++ /dev/null @@ -1,505 +0,0 @@ -[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/skwasjer/MockHttp")] -[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName=".NET Standard 2.1")] -namespace MockHttp -{ - public static class AuthenticationRequestMatchingExtensions - { - public static MockHttp.RequestMatching BearerToken(this MockHttp.RequestMatching builder) { } - public static MockHttp.RequestMatching BearerToken(this MockHttp.RequestMatching builder, string token) { } - } - public sealed class BitRate - { - public override string ToString() { } - public static MockHttp.BitRate FiveG() { } - public static MockHttp.BitRate FourG() { } - public static MockHttp.BitRate FromInt32(int bitRate) { } - public static MockHttp.BitRate OneGigabit() { } - public static MockHttp.BitRate OneHundredMegabit() { } - public static MockHttp.BitRate TenMegabit() { } - public static MockHttp.BitRate ThreeG() { } - public static int ToInt32(MockHttp.BitRate bitRate) { } - public static MockHttp.BitRate TwoG() { } - public static int op_Explicit(MockHttp.BitRate bitRate) { } - public static MockHttp.BitRate op_Explicit(int bitRate) { } - } - [System.Serializable] - public class HttpMockException : System.Exception - { - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - protected HttpMockException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } - } - public interface IFluentInterface - { - bool Equals(object obj); - int GetHashCode(); - System.Type GetType(); - string ToString(); - } - public interface IInvokedHttpRequest - { - System.Collections.Generic.IReadOnlyCollection Matchers { get; } - System.Net.Http.HttpRequestMessage Request { get; } - } - public interface IInvokedHttpRequestCollection : MockHttp.Threading.IConcurrentReadOnlyCollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable - { - void Clear(); - } - public interface IMockConfiguration - { - System.Collections.Generic.IReadOnlyDictionary Items { get; } - MockHttp.IMockConfiguration Use(TService service); - } - public static class IRespondsExtensions - { - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) - where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) - where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Action with) - where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Func response) - where TResult : MockHttp.Language.Flow.IResponseResult { } - public static TResult Respond(this MockHttp.Language.IResponds responds, System.Func response) - where TResult : MockHttp.Language.Flow.IResponseResult { } - } - public interface IResponseBuilder : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithContent, MockHttp.Language.Response.IWithHeaders, MockHttp.Language.Response.IWithResponse, MockHttp.Language.Response.IWithStatusCode { } - public sealed class IsSent - { - public override string ToString() { } - public static MockHttp.IsSent AtLeast(int callCount) { } - public static MockHttp.IsSent AtLeastOnce() { } - public static MockHttp.IsSent AtMost(int callCount) { } - public static MockHttp.IsSent AtMostOnce() { } - public static MockHttp.IsSent Exactly(int callCount) { } - public static MockHttp.IsSent Never() { } - public static MockHttp.IsSent Once() { } - } - public sealed class MockHttpHandler : System.Net.Http.HttpMessageHandler, MockHttp.IMockConfiguration - { - public static readonly System.Text.Encoding DefaultEncoding; - public MockHttpHandler() { } - public MockHttp.Language.IRespondsThrows Fallback { get; } - public MockHttp.IInvokedHttpRequestCollection InvokedRequests { get; } - public void Reset() { } - protected override System.Threading.Tasks.Task SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { } - public void Verify() { } - public void Verify(System.Action matching, MockHttp.IsSent times, string? because = null) { } - public void Verify(System.Action matching, System.Func times, string? because = null) { } - public void VerifyAll() { } - public System.Threading.Tasks.Task VerifyAsync(System.Action matching, MockHttp.IsSent times, string? because = null) { } - public System.Threading.Tasks.Task VerifyAsync(System.Action matching, System.Func times, string? because = null) { } - public void VerifyNoOtherRequests() { } - public MockHttp.Language.IConfiguredRequest When(System.Action matching) { } - } - public class NetworkLatency - { - public override string ToString() { } - public static MockHttp.NetworkLatency Around(int latencyInMs) { } - public static MockHttp.NetworkLatency Around(System.TimeSpan latency) { } - public static MockHttp.NetworkLatency Between(int minMs, int maxMs) { } - public static MockHttp.NetworkLatency Between(System.TimeSpan min, System.TimeSpan max) { } - public static MockHttp.NetworkLatency FiveG() { } - public static MockHttp.NetworkLatency FourG() { } - public static MockHttp.NetworkLatency ThreeG() { } - public static MockHttp.NetworkLatency TwoG() { } - } - public class RequestMatching : MockHttp.IFluentInterface - { - public MockHttp.RequestMatching Not { get; } - protected virtual MockHttp.RequestMatching RegisterMatcher(MockHttp.Matchers.IAsyncHttpRequestMatcher matcher) { } - protected virtual void ValidateMatcher(MockHttp.Matchers.IAsyncHttpRequestMatcher matcher) { } - public MockHttp.RequestMatching With(MockHttp.Matchers.IAsyncHttpRequestMatcher matcher) { } - } - public static class RequestMatchingExtensions - { - public static MockHttp.RequestMatching Any(this MockHttp.RequestMatching builder, System.Action anyBuilder) { } - public static MockHttp.RequestMatching Body(this MockHttp.RequestMatching builder, byte[] body) { } - public static MockHttp.RequestMatching Body(this MockHttp.RequestMatching builder, System.IO.Stream body) { } - public static MockHttp.RequestMatching Body(this MockHttp.RequestMatching builder, string body) { } - public static MockHttp.RequestMatching Body(this MockHttp.RequestMatching builder, string body, System.Text.Encoding encoding) { } - public static MockHttp.RequestMatching ContentType(this MockHttp.RequestMatching builder, System.Net.Http.Headers.MediaTypeHeaderValue mediaType) { } - public static MockHttp.RequestMatching ContentType(this MockHttp.RequestMatching builder, string mediaType) { } - public static MockHttp.RequestMatching ContentType(this MockHttp.RequestMatching builder, string contentType, System.Text.Encoding encoding) { } - public static MockHttp.RequestMatching FormData(this MockHttp.RequestMatching builder, System.Collections.Generic.IEnumerable>> formData) { } - public static MockHttp.RequestMatching FormData(this MockHttp.RequestMatching builder, System.Collections.Generic.IEnumerable> formData) { } - public static MockHttp.RequestMatching FormData(this MockHttp.RequestMatching builder, System.Collections.Specialized.NameValueCollection formData) { } - public static MockHttp.RequestMatching FormData(this MockHttp.RequestMatching builder, string urlEncodedFormData) { } - public static MockHttp.RequestMatching FormData(this MockHttp.RequestMatching builder, string key, string value) { } - public static MockHttp.RequestMatching Header(this MockHttp.RequestMatching builder, string name) { } - public static MockHttp.RequestMatching Header(this MockHttp.RequestMatching builder, string name, System.Collections.Generic.IEnumerable values) { } - public static MockHttp.RequestMatching Header(this MockHttp.RequestMatching builder, string name, System.DateTime date) { } - public static MockHttp.RequestMatching Header(this MockHttp.RequestMatching builder, string name, System.DateTimeOffset date) { } - public static MockHttp.RequestMatching Header(this MockHttp.RequestMatching builder, string name, params string[] values) { } - public static MockHttp.RequestMatching Header(this MockHttp.RequestMatching builder, string name, string value, bool allowWildcards) { } - public static MockHttp.RequestMatching Header(this MockHttp.RequestMatching builder, string name, T value) - where T : struct { } - public static MockHttp.RequestMatching Headers(this MockHttp.RequestMatching builder, System.Collections.Generic.IEnumerable>> headers) { } - public static MockHttp.RequestMatching Headers(this MockHttp.RequestMatching builder, System.Collections.Generic.IEnumerable> headers) { } - public static MockHttp.RequestMatching Headers(this MockHttp.RequestMatching builder, string headers) { } - public static MockHttp.RequestMatching Method(this MockHttp.RequestMatching builder, System.Net.Http.HttpMethod method) { } - public static MockHttp.RequestMatching Method(this MockHttp.RequestMatching builder, string httpMethod) { } - public static MockHttp.RequestMatching PartialBody(this MockHttp.RequestMatching builder, byte[] partialBody) { } - public static MockHttp.RequestMatching PartialBody(this MockHttp.RequestMatching builder, System.IO.Stream partialBody) { } - public static MockHttp.RequestMatching PartialBody(this MockHttp.RequestMatching builder, string partialBody) { } - public static MockHttp.RequestMatching PartialBody(this MockHttp.RequestMatching builder, string partialBody, System.Text.Encoding encoding) { } - public static MockHttp.RequestMatching QueryString(this MockHttp.RequestMatching builder, System.Collections.Generic.IEnumerable>> parameters) { } - public static MockHttp.RequestMatching QueryString(this MockHttp.RequestMatching builder, System.Collections.Specialized.NameValueCollection parameters) { } - public static MockHttp.RequestMatching QueryString(this MockHttp.RequestMatching builder, string queryString) { } - public static MockHttp.RequestMatching QueryString(this MockHttp.RequestMatching builder, string key, System.Collections.Generic.IEnumerable values) { } - public static MockHttp.RequestMatching QueryString(this MockHttp.RequestMatching builder, string key, params string[] values) { } - public static MockHttp.RequestMatching QueryString(this MockHttp.RequestMatching builder, string key, string? value) { } - public static MockHttp.RequestMatching RequestUri(this MockHttp.RequestMatching builder, string requestUri) { } - public static MockHttp.RequestMatching RequestUri(this MockHttp.RequestMatching builder, System.Uri requestUri) { } - public static MockHttp.RequestMatching Version(this MockHttp.RequestMatching builder, string version) { } - public static MockHttp.RequestMatching Version(this MockHttp.RequestMatching builder, System.Version version) { } - public static MockHttp.RequestMatching Where(this MockHttp.RequestMatching builder, System.Linq.Expressions.Expression> expression) { } - public static MockHttp.RequestMatching WithoutBody(this MockHttp.RequestMatching builder) { } - public static MockHttp.RequestMatching WithoutQueryString(this MockHttp.RequestMatching builder) { } - } - public static class ResponseBuilderExtensions - { - public static MockHttp.Language.Flow.Response.IWithContentResult Body(this MockHttp.Language.Response.IWithContent builder, byte[] binaryContent) { } - public static MockHttp.Language.Flow.Response.IWithContentResult Body(this MockHttp.Language.Response.IWithContent builder, System.Func streamContentFactory) { } - public static MockHttp.Language.Flow.Response.IWithContentResult Body(this MockHttp.Language.Response.IWithContent builder, System.Func> streamContentFactory) { } - public static MockHttp.Language.Flow.Response.IWithContentResult Body(this MockHttp.Language.Response.IWithContent builder, System.IO.Stream streamContent) { } - public static MockHttp.Language.Flow.Response.IWithContentResult Body(this MockHttp.Language.Response.IWithContent builder, System.Net.Http.HttpContent httpContent) { } - public static MockHttp.Language.Flow.Response.IWithContentResult Body(this MockHttp.Language.Response.IWithContent builder, string textContent, System.Text.Encoding? encoding = null) { } - public static MockHttp.Language.Flow.Response.IWithContentResult Body(this MockHttp.Language.Response.IWithContent builder, byte[] binaryContent, int offset, int count) { } - public static MockHttp.Language.Response.IWithResponse ClientTimeout(this MockHttp.IResponseBuilder builder, System.TimeSpan? timeoutAfter = default) { } - public static MockHttp.Language.Flow.Response.IWithHeadersResult ContentType(this MockHttp.Language.Response.IWithContentType builder, string mediaType, System.Text.Encoding? encoding = null) { } - public static MockHttp.Language.Flow.Response.IWithHeadersResult Header(this MockHttp.Language.Response.IWithHeaders builder, System.Collections.Generic.KeyValuePair> header) { } - public static MockHttp.Language.Flow.Response.IWithHeadersResult Header(this MockHttp.Language.Response.IWithHeaders builder, System.Collections.Generic.KeyValuePair header) { } - public static MockHttp.Language.Flow.Response.IWithHeadersResult Header(this MockHttp.Language.Response.IWithHeaders builder, string name, System.Collections.Generic.IEnumerable value) { } - public static MockHttp.Language.Flow.Response.IWithHeadersResult Header(this MockHttp.Language.Response.IWithHeaders builder, string name, params T[] value) { } - public static MockHttp.Language.Response.IWithResponse Latency(this MockHttp.Language.Response.IWithResponse builder, MockHttp.NetworkLatency latency) { } - public static MockHttp.Language.Response.IWithResponse Latency(this MockHttp.Language.Response.IWithResponse builder, System.Func latency) { } - public static MockHttp.Language.Flow.Response.IWithStatusCodeResult ServerTimeout(this MockHttp.IResponseBuilder builder, System.TimeSpan? timeoutAfter = default) { } - public static MockHttp.Language.Flow.Response.IWithStatusCodeResult StatusCode(this MockHttp.Language.Response.IWithStatusCode builder, int statusCode, string? reasonPhrase = null) { } - public static MockHttp.Language.Response.IWithResponse TransferRate(this MockHttp.Language.Response.IWithResponse builder, MockHttp.BitRate bitRate) { } - public static MockHttp.Language.Response.IWithResponse TransferRate(this MockHttp.Language.Response.IWithResponse builder, System.Func bitRate) { } - public static MockHttp.Language.Response.IWithResponse TransferRate(this MockHttp.Language.Response.IWithResponse builder, int bitRate) { } - } - public static class ResponseBuilderLinqToXmlExtensions - { - public static MockHttp.Language.Flow.Response.IWithContentResult XmlBody(this MockHttp.Language.Response.IWithContent builder, System.Xml.Linq.XContainer xmlContent, System.Xml.XmlWriterSettings? settings = null) { } - } -} -namespace MockHttp.Http -{ - public static class HeaderNames - { - public const string Accept = "Accept"; - public const string AcceptCharset = "Accept-Charset"; - public const string AcceptEncoding = "Accept-Encoding"; - public const string AcceptLanguage = "Accept-Language"; - public const string AcceptRanges = "Accept-Ranges"; - public const string AccessControlAllowCredentials = "Access-Control-Allow-Credentials"; - public const string AccessControlAllowHeaders = "Access-Control-Allow-Headers"; - public const string AccessControlAllowMethods = "Access-Control-Allow-Methods"; - public const string AccessControlAllowOrigin = "Access-Control-Allow-Origin"; - public const string AccessControlExposeHeaders = "Access-Control-Expose-Headers"; - public const string AccessControlMaxAge = "Access-Control-Max-Age"; - public const string AccessControlRequestHeaders = "Access-Control-Request-Headers"; - public const string AccessControlRequestMethod = "Access-Control-Request-Method"; - public const string Age = "Age"; - public const string Allow = "Allow"; - public const string Authority = ":authority"; - public const string Authorization = "Authorization"; - public const string CacheControl = "Cache-Control"; - public const string Connection = "Connection"; - public const string ContentDisposition = "Content-Disposition"; - public const string ContentEncoding = "Content-Encoding"; - public const string ContentLanguage = "Content-Language"; - public const string ContentLength = "Content-Length"; - public const string ContentLocation = "Content-Location"; - public const string ContentMD5 = "Content-MD5"; - public const string ContentRange = "Content-Range"; - public const string ContentSecurityPolicy = "Content-Security-Policy"; - public const string ContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only"; - public const string ContentType = "Content-Type"; - public const string Cookie = "Cookie"; - public const string CorrelationContext = "Correlation-Context"; - public const string DNT = "DNT"; - public const string Date = "Date"; - public const string ETag = "ETag"; - public const string Expect = "Expect"; - public const string Expires = "Expires"; - public const string From = "From"; - public const string Host = "Host"; - public const string IfMatch = "If-Match"; - public const string IfModifiedSince = "If-Modified-Since"; - public const string IfNoneMatch = "If-None-Match"; - public const string IfRange = "If-Range"; - public const string IfUnmodifiedSince = "If-Unmodified-Since"; - public const string KeepAlive = "Keep-Alive"; - public const string LastModified = "Last-Modified"; - public const string Location = "Location"; - public const string MaxForwards = "Max-Forwards"; - public const string Method = ":method"; - public const string Origin = "Origin"; - public const string Path = ":path"; - public const string Pragma = "Pragma"; - public const string ProxyAuthenticate = "Proxy-Authenticate"; - public const string ProxyAuthorization = "Proxy-Authorization"; - public const string Range = "Range"; - public const string Referer = "Referer"; - public const string RequestId = "Request-Id"; - public const string RetryAfter = "Retry-After"; - public const string Scheme = ":scheme"; - public const string SecWebSocketAccept = "Sec-WebSocket-Accept"; - public const string SecWebSocketKey = "Sec-WebSocket-Key"; - public const string SecWebSocketProtocol = "Sec-WebSocket-Protocol"; - public const string SecWebSocketVersion = "Sec-WebSocket-Version"; - public const string Server = "Server"; - public const string SetCookie = "Set-Cookie"; - public const string Status = ":status"; - public const string StrictTransportSecurity = "Strict-Transport-Security"; - public const string TE = "TE"; - public const string TraceParent = "traceparent"; - public const string TraceState = "tracestate"; - public const string Trailer = "Trailer"; - public const string TransferEncoding = "Transfer-Encoding"; - public const string Translate = "Translate"; - public const string Upgrade = "Upgrade"; - public const string UpgradeInsecureRequests = "Upgrade-Insecure-Requests"; - public const string UserAgent = "User-Agent"; - public const string Vary = "Vary"; - public const string Via = "Via"; - public const string WWWAuthenticate = "WWW-Authenticate"; - public const string Warning = "Warning"; - public const string WebSocketSubProtocols = "Sec-WebSocket-Protocol"; - public const string XFrameOptions = "X-Frame-Options"; - } - public static class MediaTypes - { - public const string FormUrlEncoded = "application/x-www-form-urlencoded"; - public const string Html = "text/html"; - public const string Json = "application/json"; - public const string JsonProblemDetails = "application/problem+json"; - public const string MultipartFormData = "multipart/form-data"; - public const string OctetStream = "application/octet-stream"; - public const string PlainText = "text/plain"; - public const string Xml = "application/xml"; - public const string XmlProblemDetails = "application/problem+xml"; - } -} -namespace MockHttp.IO -{ - public class RateLimitedStream : System.IO.Stream - { - public RateLimitedStream(System.IO.Stream actualStream, int bitRate, bool leaveOpen = false) { } - public override bool CanRead { get; } - public override bool CanSeek { get; } - public override bool CanWrite { get; } - public override long Length { get; } - public override long Position { get; set; } - protected override void Dispose(bool disposing) { } - public override void Flush() { } - public override int Read(byte[] buffer, int offset, int count) { } - public override long Seek(long offset, System.IO.SeekOrigin origin) { } - public override void SetLength(long value) { } - public override void Write(byte[] buffer, int offset, int count) { } - } -} -namespace MockHttp.Language.Flow -{ - public interface ICallbackResult : MockHttp.IFluentInterface, MockHttp.Language.IResponds, MockHttp.Language.IThrows - where out TResponseResult : MockHttp.Language.Flow.IResponseResult - where out TThrowsResult : MockHttp.Language.Flow.IThrowsResult { } - public interface IResponseResult : MockHttp.IFluentInterface { } - public interface ISequenceResponseResult : MockHttp.IFluentInterface, MockHttp.Language.Flow.IResponseResult, MockHttp.Language.IResponds, MockHttp.Language.IThrows, MockHttp.Language.IVerifies { } - public interface ISequenceThrowsResult : MockHttp.IFluentInterface, MockHttp.Language.Flow.IThrowsResult, MockHttp.Language.IResponds, MockHttp.Language.IThrows, MockHttp.Language.IVerifies { } - public interface IThrowsResult : MockHttp.IFluentInterface { } -} -namespace MockHttp.Language.Flow.Response -{ - public interface IWithContentResult : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithContentType, MockHttp.Language.Response.IWithHeaders, MockHttp.Language.Response.IWithResponse { } - public interface IWithHeadersResult : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithHeaders, MockHttp.Language.Response.IWithResponse { } - public interface IWithStatusCodeResult : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithContent, MockHttp.Language.Response.IWithHeaders, MockHttp.Language.Response.IWithResponse { } -} -namespace MockHttp.Language -{ - public interface ICallback : MockHttp.IFluentInterface - where out TResponseResult : MockHttp.Language.Flow.IResponseResult - where out TThrowsResult : MockHttp.Language.Flow.IThrowsResult - { - MockHttp.Language.Flow.ICallbackResult Callback(System.Action callback); - MockHttp.Language.Flow.ICallbackResult Callback(System.Action callback); - } - public interface IConfiguredRequest : MockHttp.IFluentInterface, MockHttp.Language.Flow.ICallbackResult, MockHttp.Language.Flow.IResponseResult, MockHttp.Language.Flow.ISequenceResponseResult, MockHttp.Language.Flow.ISequenceThrowsResult, MockHttp.Language.Flow.IThrowsResult, MockHttp.Language.ICallback, MockHttp.Language.IResponds, MockHttp.Language.IThrows, MockHttp.Language.IVerifies { } - public interface IRespondsThrows : MockHttp.IFluentInterface, MockHttp.Language.IResponds, MockHttp.Language.IThrows { } - public interface IResponds : MockHttp.IFluentInterface - where out TResult : MockHttp.Language.Flow.IResponseResult - { - TResult RespondUsing(MockHttp.Responses.IResponseStrategy responseStrategy); - } - public interface IThrows : MockHttp.IFluentInterface - where out TResult : MockHttp.Language.Flow.IThrowsResult - { - TResult Throws(System.Exception exception); - TResult Throws() - where TException : System.Exception, new (); - } - public interface IVerifies : MockHttp.IFluentInterface - { - void Verifiable(); - void Verifiable(string because); - } -} -namespace MockHttp.Language.Response -{ - public interface IWithContent : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithResponse - { - MockHttp.Language.Flow.Response.IWithContentResult Body(System.Func> httpContentFactory); - } - public interface IWithContentType : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithResponse - { - MockHttp.Language.Flow.Response.IWithHeadersResult ContentType(System.Net.Http.Headers.MediaTypeHeaderValue mediaType); - } - public interface IWithHeaders : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithResponse - { - MockHttp.Language.Flow.Response.IWithHeadersResult Headers(System.Collections.Generic.IEnumerable>> headers); - } - public interface IWithResponse : MockHttp.IFluentInterface - { - System.Collections.Generic.IList Behaviors { get; } - } - public interface IWithStatusCode : MockHttp.IFluentInterface, MockHttp.Language.Response.IWithContent, MockHttp.Language.Response.IWithResponse - { - MockHttp.Language.Flow.Response.IWithStatusCodeResult StatusCode(System.Net.HttpStatusCode statusCode, string? reasonPhrase = null); - } -} -namespace MockHttp.Matchers -{ - public class AnyMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public AnyMatcher(System.Collections.Generic.IReadOnlyCollection matchers) { } - public bool IsExclusive { get; } - public System.Collections.Generic.IReadOnlyCollection Matchers { get; } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ContentMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public ContentMatcher() { } - public ContentMatcher(byte[] content) { } - public ContentMatcher(string content, System.Text.Encoding? encoding) { } - protected System.Collections.Generic.IReadOnlyList ByteContent { get; } - public virtual bool IsExclusive { get; } - protected virtual bool IsMatch(byte[] requestContent) { } - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class ExpressionMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public ExpressionMatcher(System.Linq.Expressions.Expression> expression) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class FormDataMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - public FormDataMatcher(System.Collections.Generic.IEnumerable>> formData) { } - public FormDataMatcher(string urlEncodedFormData) { } - public virtual bool IsExclusive { get; } - public virtual System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpHeadersMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable>> headers) { } - public HttpHeadersMatcher(System.Collections.Generic.IEnumerable> headers) { } - public HttpHeadersMatcher(string name) { } - public HttpHeadersMatcher(string name, System.Collections.Generic.IEnumerable values) { } - public HttpHeadersMatcher(string name, string value, bool allowWildcards = false) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class HttpMethodMatcher : MockHttp.Matchers.ValueMatcher - { - public HttpMethodMatcher(System.Net.Http.HttpMethod method) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class HttpRequestMatcher : MockHttp.Matchers.IAsyncHttpRequestMatcher - { - protected HttpRequestMatcher() { } - public virtual bool IsExclusive { get; } - public abstract bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext); - public System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public abstract override string ToString() { } - } - public interface IAsyncHttpRequestMatcher - { - bool IsExclusive { get; } - System.Threading.Tasks.Task IsMatchAsync(MockHttp.Responses.MockHttpRequestContext requestContext); - } - public class MediaTypeHeaderMatcher : MockHttp.Matchers.ValueMatcher - { - public MediaTypeHeaderMatcher(System.Net.Http.Headers.MediaTypeHeaderValue headerValue) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public class PartialContentMatcher : MockHttp.Matchers.ContentMatcher - { - public PartialContentMatcher(byte[] content) { } - public PartialContentMatcher(string content, System.Text.Encoding? encoding) { } - public override bool IsExclusive { get; } - protected override bool IsMatch(byte[] requestContent) { } - public override string ToString() { } - } - public class QueryStringMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public QueryStringMatcher(System.Collections.Generic.IEnumerable>> parameters) { } - public QueryStringMatcher(string queryString) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - [System.Obsolete("Replaced with UriMatcher. Will be removed in next major release.")] - public class RequestUriMatcher : MockHttp.Matchers.HttpRequestMatcher - { - public RequestUriMatcher(System.Uri uri) { } - public RequestUriMatcher(string uriString, bool allowWildcards = true) { } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } - public abstract class ValueMatcher : MockHttp.Matchers.HttpRequestMatcher - { - protected ValueMatcher(T value) { } - protected T Value { get; } - } - public class VersionMatcher : MockHttp.Matchers.ValueMatcher - { - public VersionMatcher(System.Version version) { } - public override bool IsExclusive { get; } - public override bool IsMatch(MockHttp.Responses.MockHttpRequestContext requestContext) { } - public override string ToString() { } - } -} -namespace MockHttp.Responses -{ - public interface IResponseBehavior - { - System.Threading.Tasks.Task HandleAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, MockHttp.Responses.ResponseHandlerDelegate next, System.Threading.CancellationToken cancellationToken); - } - public interface IResponseStrategy - { - System.Threading.Tasks.Task ProduceResponseAsync(MockHttp.Responses.MockHttpRequestContext requestContext, System.Threading.CancellationToken cancellationToken); - } - public class MockHttpRequestContext - { - public MockHttpRequestContext(System.Net.Http.HttpRequestMessage request, System.Collections.Generic.IReadOnlyDictionary? services = null) { } - public System.Net.Http.HttpRequestMessage Request { get; } - public System.Collections.Generic.IReadOnlyDictionary Services { get; } - public bool TryGetService([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] out TService? service) { } - } - public delegate System.Threading.Tasks.Task ResponseHandlerDelegate(MockHttp.Responses.MockHttpRequestContext requestContext, System.Net.Http.HttpResponseMessage responseMessage, System.Threading.CancellationToken cancellationToken); -} -namespace MockHttp.Threading -{ - [System.Obsolete("Will be removed in next version.")] - public interface IConcurrentReadOnlyCollection : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable { } -} \ No newline at end of file