From 3e09a51e085af720575ceb7330a9b05ac5f17d86 Mon Sep 17 00:00:00 2001 From: Alexey Zimarev Date: Wed, 3 Apr 2024 17:56:48 +0200 Subject: [PATCH] Cleaning up fixtures --- Directory.Packages.props | 1 + .../CsvHelperSerializer.cs | 18 +-- src/RestSharp/ContentType.cs | 3 +- .../DefaultParameterTests.cs | 1 + .../DownloadFileTests.cs | 77 ++++++------- .../JsonBodyTests.cs | 1 + .../MultipartFormDataTests.cs | 1 + test/RestSharp.Tests.Integrated/ProxyTests.cs | 6 +- .../RequestBodyTests.cs | 1 + .../RootElementTests.cs | 38 +++--- .../StructuredSyntaxSuffixTests.cs | 46 +++++--- .../CsvHelperTests.cs | 92 ++++++--------- .../RestSharp.Tests.Serializers.Csv.csproj | 9 ++ .../NewtonsoftJson/IntegratedSimpleTests.cs | 77 ++++--------- .../NewtonsoftJson/IntegratedTests.cs | 23 ++-- .../RestSharp.Tests.Serializers.Json.csproj | 18 +-- .../SystemTextJson/SystemTextJsonTests.cs | 65 ++++------- .../Fixtures/Handlers.cs | 5 - .../Fixtures/HttpServerFixture.cs | 23 ---- .../Fixtures/RequestBodyCapturer.cs | 2 +- .../Fixtures/TestHttpServer.cs | 109 ------------------ .../Fixtures/TestHttpServerExtensions.cs | 19 --- .../Fixtures/TestRequestHandler.cs | 57 --------- .../Fixtures/WireMockExtensions.cs | 9 +- .../RestSharp.Tests.Shared.csproj | 6 + 25 files changed, 216 insertions(+), 491 deletions(-) delete mode 100644 test/RestSharp.Tests.Shared/Fixtures/HttpServerFixture.cs rename test/{RestSharp.Tests.Integrated => RestSharp.Tests.Shared}/Fixtures/RequestBodyCapturer.cs (95%) delete mode 100644 test/RestSharp.Tests.Shared/Fixtures/TestHttpServer.cs delete mode 100644 test/RestSharp.Tests.Shared/Fixtures/TestHttpServerExtensions.cs delete mode 100644 test/RestSharp.Tests.Shared/Fixtures/TestRequestHandler.cs rename test/{RestSharp.Tests.Integrated => RestSharp.Tests.Shared}/Fixtures/WireMockExtensions.cs (74%) diff --git a/Directory.Packages.props b/Directory.Packages.props index 265862dd2..129ca2884 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -15,6 +15,7 @@ + diff --git a/src/RestSharp.Serializers.CsvHelper/CsvHelperSerializer.cs b/src/RestSharp.Serializers.CsvHelper/CsvHelperSerializer.cs index 96c19536c..ac4c852c0 100644 --- a/src/RestSharp.Serializers.CsvHelper/CsvHelperSerializer.cs +++ b/src/RestSharp.Serializers.CsvHelper/CsvHelperSerializer.cs @@ -5,26 +5,20 @@ namespace RestSharp.Serializers.CsvHelper; -public class CsvHelperSerializer : IDeserializer, IRestSerializer, ISerializer { - const string TextCsvContentType = "text/csv"; - - readonly CsvConfiguration _configuration; - +public class CsvHelperSerializer(CsvConfiguration configuration) : IDeserializer, IRestSerializer, ISerializer { public ISerializer Serializer => this; public IDeserializer Deserializer => this; - public string[] AcceptedContentTypes => new[] { TextCsvContentType, "application/x-download" }; + public string[] AcceptedContentTypes => [ContentType.Csv, "application/x-download"]; public SupportsContentType SupportsContentType => x => Array.IndexOf(AcceptedContentTypes, x) != -1 || x.Value.Contains("csv"); public DataFormat DataFormat => DataFormat.None; - public ContentType ContentType { get; set; } = TextCsvContentType; - - public CsvHelperSerializer() => _configuration = new CsvConfiguration(CultureInfo.InvariantCulture); + public ContentType ContentType { get; set; } = ContentType.Csv; - public CsvHelperSerializer(CsvConfiguration configuration) => _configuration = configuration; + public CsvHelperSerializer() : this(new CsvConfiguration(CultureInfo.InvariantCulture)) { } public T? Deserialize(RestResponse response) { try { @@ -33,7 +27,7 @@ public class CsvHelperSerializer : IDeserializer, IRestSerializer, ISerializer { using var stringReader = new StringReader(response.Content); - using var csvReader = new CsvReader(stringReader, _configuration); + using var csvReader = new CsvReader(stringReader, configuration); var @interface = typeof(T).GetInterface("IEnumerable`1"); @@ -81,7 +75,7 @@ public class CsvHelperSerializer : IDeserializer, IRestSerializer, ISerializer { using var stringWriter = new StringWriter(); - using var csvWriter = new CsvWriter(stringWriter, _configuration); + using var csvWriter = new CsvWriter(stringWriter, configuration); if (obj is IEnumerable records) { csvWriter.WriteRecords(records); diff --git a/src/RestSharp/ContentType.cs b/src/RestSharp/ContentType.cs index 54bec16e8..3a277de69 100644 --- a/src/RestSharp/ContentType.cs +++ b/src/RestSharp/ContentType.cs @@ -29,6 +29,7 @@ public class ContentType : IEquatable { public static readonly ContentType Json = "application/json"; public static readonly ContentType Xml = "application/xml"; public static readonly ContentType Plain = "text/plain"; + public static readonly ContentType Csv = "text/csv"; public static readonly ContentType Binary = "application/octet-stream"; public static readonly ContentType GZip = "application/x-gzip"; public static readonly ContentType FormUrlEncoded = "application/x-www-form-urlencoded"; @@ -84,4 +85,4 @@ public override bool Equals(object? obj) { } public override int GetHashCode() => _value.GetHashCode(); -} +} \ No newline at end of file diff --git a/test/RestSharp.Tests.Integrated/DefaultParameterTests.cs b/test/RestSharp.Tests.Integrated/DefaultParameterTests.cs index b371090fc..12ee9dc18 100644 --- a/test/RestSharp.Tests.Integrated/DefaultParameterTests.cs +++ b/test/RestSharp.Tests.Integrated/DefaultParameterTests.cs @@ -1,5 +1,6 @@ using RestSharp.Tests.Integrated.Fixtures; using RestSharp.Tests.Integrated.Server; +using RestSharp.Tests.Shared.Fixtures; namespace RestSharp.Tests.Integrated; diff --git a/test/RestSharp.Tests.Integrated/DownloadFileTests.cs b/test/RestSharp.Tests.Integrated/DownloadFileTests.cs index f2cd59482..2dcae0ac6 100644 --- a/test/RestSharp.Tests.Integrated/DownloadFileTests.cs +++ b/test/RestSharp.Tests.Integrated/DownloadFileTests.cs @@ -1,64 +1,56 @@ -using System.Net; -using System.Text; -using RestSharp.Tests.Shared.Fixtures; +using System.Text; namespace RestSharp.Tests.Integrated; public sealed class DownloadFileTests : IDisposable { + const string LocalPath = "Assets/Koala.jpg"; + public DownloadFileTests() { - _server = HttpServerFixture.StartServer("Assets/Koala.jpg", FileHandler); - var options = new RestClientOptions(_server.Url) { ThrowOnAnyError = true }; + // _server = HttpServerFixture.StartServer("Assets/Koala.jpg", FileHandler); + + var pathToFile = Path.Combine(_path, Path.Combine(LocalPath.Split('/'))); + + _server + .Given(Request.Create().WithPath($"/{LocalPath}")) + .RespondWith(Response.Create().WithBodyFromFile(pathToFile)); + var options = new RestClientOptions($"{_server.Url}/{LocalPath}") { ThrowOnAnyError = true }; _client = new RestClient(options); } public void Dispose() => _server.Dispose(); - void FileHandler(HttpListenerRequest request, HttpListenerResponse response) { - var pathToFile = Path.Combine( - _path, - Path.Combine( - request.Url!.Segments.Select(s => s.Replace("/", "")).ToArray() - ) - ); - - using var reader = new StreamReader(pathToFile); - - reader.BaseStream.CopyTo(response.OutputStream); - } - - readonly HttpServerFixture _server; - readonly RestClient _client; - readonly string _path = AppDomain.CurrentDomain.BaseDirectory; + readonly WireMockServer _server = WireMockServer.Start(); + readonly RestClient _client; + readonly string _path = AppDomain.CurrentDomain.BaseDirectory; [Fact] public async Task AdvancedResponseWriter_without_ResponseWriter_reads_stream() { var tag = string.Empty; - // ReSharper disable once UseObjectOrCollectionInitializer - var rr = new RestRequest("Assets/Koala.jpg"); - - rr.AdvancedResponseWriter = (response, request) => { - var buf = new byte[16]; - // ReSharper disable once MustUseReturnValue - response.Content.ReadAsStream().Read(buf, 0, buf.Length); - tag = Encoding.ASCII.GetString(buf, 6, 4); - return new RestResponse(request); + var rr = new RestRequest("") { + AdvancedResponseWriter = (response, request) => { + var buf = new byte[16]; + // ReSharper disable once MustUseReturnValue + response.Content.ReadAsStream().Read(buf, 0, buf.Length); + tag = Encoding.ASCII.GetString(buf, 6, 4); + return new RestResponse(request); + } }; await _client.ExecuteAsync(rr); - Assert.True(string.Compare("JFIF", tag, StringComparison.Ordinal) == 0); + Assert.Equal(0, string.Compare("JFIF", tag, StringComparison.Ordinal)); } [Fact] public async Task Handles_File_Download_Failure() { - var request = new RestRequest("Assets/Koala1.jpg"); + var request = new RestRequest(""); var task = () => _client.DownloadDataAsync(request); await task.Should().ThrowAsync().WithMessage("Request failed with status code NotFound"); } [Fact] public async Task Handles_Binary_File_Download() { - var request = new RestRequest("Assets/Koala.jpg"); + var request = new RestRequest(""); var response = await _client.DownloadDataAsync(request); var expected = await File.ReadAllBytesAsync(Path.Combine(_path, "Assets", "Koala.jpg")); @@ -69,22 +61,21 @@ public async Task Handles_Binary_File_Download() { public async Task Writes_Response_To_Stream() { var tempFile = Path.GetTempFileName(); - // ReSharper disable once UseObjectOrCollectionInitializer - var request = new RestRequest("Assets/Koala.jpg"); - - request.ResponseWriter = responseStream => { - using var writer = File.OpenWrite(tempFile); - - responseStream.CopyTo(writer); - return null; + var request = new RestRequest("") { + ResponseWriter = responseStream => { + using var writer = File.OpenWrite(tempFile); + responseStream.CopyTo(writer); + return null; + } }; + var response = await _client.DownloadDataAsync(request); Assert.Null(response); var fromTemp = await File.ReadAllBytesAsync(tempFile); - var expected = await File.ReadAllBytesAsync(Path.Combine(_path, "Assets", "Koala.jpg")); + var expected = await File.ReadAllBytesAsync(Path.Combine(_path, Path.Combine(LocalPath.Split('/')))); Assert.Equal(expected, fromTemp); } -} +} \ No newline at end of file diff --git a/test/RestSharp.Tests.Integrated/JsonBodyTests.cs b/test/RestSharp.Tests.Integrated/JsonBodyTests.cs index 8d2025eae..bc7efb201 100644 --- a/test/RestSharp.Tests.Integrated/JsonBodyTests.cs +++ b/test/RestSharp.Tests.Integrated/JsonBodyTests.cs @@ -1,5 +1,6 @@ using System.Text.Json; using RestSharp.Tests.Integrated.Fixtures; +using RestSharp.Tests.Shared.Fixtures; namespace RestSharp.Tests.Integrated; diff --git a/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs b/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs index 7223da777..93ae61130 100644 --- a/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs +++ b/test/RestSharp.Tests.Integrated/MultipartFormDataTests.cs @@ -1,5 +1,6 @@ using HttpTracer; using RestSharp.Tests.Integrated.Fixtures; +using RestSharp.Tests.Shared.Fixtures; namespace RestSharp.Tests.Integrated; diff --git a/test/RestSharp.Tests.Integrated/ProxyTests.cs b/test/RestSharp.Tests.Integrated/ProxyTests.cs index cec1571bd..67cc0f50d 100644 --- a/test/RestSharp.Tests.Integrated/ProxyTests.cs +++ b/test/RestSharp.Tests.Integrated/ProxyTests.cs @@ -6,14 +6,14 @@ namespace RestSharp.Tests.Integrated; public class ProxyTests { [Fact] public async Task Set_Invalid_Proxy_Fails() { - using var server = HttpServerFixture.StartServer((_, _) => { }); + using var server = WireMockServer.Start(); - var client = new RestClient(new RestClientOptions(server.Url) { Proxy = new WebProxy("non_existent_proxy", false) }); + var client = new RestClient(new RestClientOptions(server.Url!) { Proxy = new WebProxy("non_existent_proxy", false) }); var request = new RestRequest(); var response = await client.ExecuteAsync(request); - Assert.False(response.IsSuccessful); + response.IsSuccessful.Should().BeFalse(); response.ErrorException.Should().BeOfType(); } } \ No newline at end of file diff --git a/test/RestSharp.Tests.Integrated/RequestBodyTests.cs b/test/RestSharp.Tests.Integrated/RequestBodyTests.cs index 2780d13d6..47ba86f04 100644 --- a/test/RestSharp.Tests.Integrated/RequestBodyTests.cs +++ b/test/RestSharp.Tests.Integrated/RequestBodyTests.cs @@ -1,4 +1,5 @@ using RestSharp.Tests.Integrated.Fixtures; +using RestSharp.Tests.Shared.Fixtures; namespace RestSharp.Tests.Integrated; diff --git a/test/RestSharp.Tests.Integrated/RootElementTests.cs b/test/RestSharp.Tests.Integrated/RootElementTests.cs index 608bf5238..3e9a0feba 100644 --- a/test/RestSharp.Tests.Integrated/RootElementTests.cs +++ b/test/RestSharp.Tests.Integrated/RootElementTests.cs @@ -1,16 +1,26 @@ -using System.Net; -using RestSharp.Serializers.Xml; -using RestSharp.Tests.Shared.Extensions; -using RestSharp.Tests.Shared.Fixtures; +using RestSharp.Serializers.Xml; namespace RestSharp.Tests.Integrated; public class RootElementTests { [Fact] public async Task Copy_RootElement_From_Request_To_IWithRootElement_Deserializer() { - using var server = HttpServerFixture.StartServer("success", Handle); - - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseXmlSerializer()); + using var server = WireMockServer.Start(); + + const string xmlBody = + """ + + + + Works! + + + """; + server + .Given(Request.Create().WithPath("/success")) + .RespondWith(Response.Create().WithBody(xmlBody).WithHeader(KnownHeaders.ContentType, ContentType.Xml)); + + var client = new RestClient(server.Url!, configureSerialization: cfg => cfg.UseXmlSerializer()); var request = new RestRequest("success") { RootElement = "Success" }; @@ -18,19 +28,5 @@ public async Task Copy_RootElement_From_Request_To_IWithRootElement_Deserializer response.Data.Should().NotBeNull(); response.Data!.Message.Should().Be("Works!"); - - static void Handle(HttpListenerRequest req, HttpListenerResponse response) { - response.StatusCode = 200; - response.Headers.Add(KnownHeaders.ContentType, ContentType.Xml); - - response.OutputStream.WriteStringUtf8( - @" - - - Works! - -" - ); - } } } \ No newline at end of file diff --git a/test/RestSharp.Tests.Integrated/StructuredSyntaxSuffixTests.cs b/test/RestSharp.Tests.Integrated/StructuredSyntaxSuffixTests.cs index 3f4d68499..5cfd56d33 100644 --- a/test/RestSharp.Tests.Integrated/StructuredSyntaxSuffixTests.cs +++ b/test/RestSharp.Tests.Integrated/StructuredSyntaxSuffixTests.cs @@ -1,15 +1,14 @@ -using System.Net; +using System.Text; using RestSharp.Serializers.Xml; -using RestSharp.Tests.Shared.Extensions; -using RestSharp.Tests.Shared.Fixtures; +using WireMock.Types; +using WireMock.Util; // ReSharper disable UnusedAutoPropertyAccessor.Local namespace RestSharp.Tests.Integrated; public sealed class StructuredSyntaxSuffixTests : IDisposable { - readonly TestHttpServer _server; - readonly string _url; + readonly WireMockServer _server; class Person { public string Name { get; set; } = null!; @@ -21,22 +20,37 @@ class Person { const string JsonContent = @"{ ""name"":""Bob"", ""age"":50 }"; public StructuredSyntaxSuffixTests() { - _server = new TestHttpServer(0, "", HandleRequest); - _url = $"http://localhost:{_server.Port}"; + _server = WireMockServer.Start(); + _server.Given(Request.Create().WithPath("/").UsingGet()).RespondWith(Response.Create().WithCallback(Handle)); return; - static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response, Dictionary p) { - response.ContentType = request.QueryString["ct"]; - response.OutputStream.WriteStringUtf8(request.QueryString["c"]); - response.StatusCode = 200; + static ResponseMessage Handle(IRequestMessage request) { + var response = new ResponseMessage { + Headers = new Dictionary> { + [KnownHeaders.ContentType] = new(request.Query!["ct"]) + }, + StatusCode = 200, + BodyData = new BodyData { + BodyAsString = request.Query["c"].First(), + Encoding = Encoding.UTF8, + DetectedBodyType = BodyType.String + } + }; + return response; } + + // static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response, Dictionary p) { + // response.ContentType = request.QueryString["ct"]; + // response.OutputStream.WriteStringUtf8(request.QueryString["c"]); + // response.StatusCode = 200; + // } } public void Dispose() => _server.Dispose(); [Fact] public async Task By_default_application_json_content_type_should_deserialize_as_JSON() { - var client = new RestClient(_url); + var client = new RestClient(_server.Url!); var request = new RestRequest() .AddParameter("ct", "application/json") @@ -50,7 +64,7 @@ public async Task By_default_application_json_content_type_should_deserialize_as [Fact] public async Task By_default_content_types_with_JSON_structured_syntax_suffix_should_deserialize_as_JSON() { - var client = new RestClient(_url); + var client = new RestClient(_server.Url!); var request = new RestRequest() .AddParameter("ct", "application/vnd.somebody.something+json") @@ -64,7 +78,7 @@ public async Task By_default_content_types_with_JSON_structured_syntax_suffix_sh [Fact] public async Task By_default_content_types_with_XML_structured_syntax_suffix_should_deserialize_as_XML() { - var client = new RestClient(_url, configureSerialization: cfg => cfg.UseXmlSerializer()); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseXmlSerializer()); var request = new RestRequest() .AddParameter("ct", "application/vnd.somebody.something+xml") @@ -78,7 +92,7 @@ public async Task By_default_content_types_with_XML_structured_syntax_suffix_sho [Fact] public async Task By_default_text_xml_content_type_should_deserialize_as_XML() { - var client = new RestClient(_url, configureSerialization: cfg => cfg.UseXmlSerializer()); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseXmlSerializer()); var request = new RestRequest() .AddParameter("ct", "text/xml") @@ -89,4 +103,4 @@ public async Task By_default_text_xml_content_type_should_deserialize_as_XML() { Assert.Equal("Bob", response.Data!.Name); Assert.Equal(50, response.Data.Age); } -} +} \ No newline at end of file diff --git a/test/RestSharp.Tests.Serializers.Csv/CsvHelperTests.cs b/test/RestSharp.Tests.Serializers.Csv/CsvHelperTests.cs index e4aee68e8..4f3202b97 100644 --- a/test/RestSharp.Tests.Serializers.Csv/CsvHelperTests.cs +++ b/test/RestSharp.Tests.Serializers.Csv/CsvHelperTests.cs @@ -9,11 +9,20 @@ namespace RestSharp.Tests.Serializers.Csv; -public class CsvHelperTests { +public sealed class CsvHelperTests : IDisposable { static readonly Fixture Fixture = new(); - [Fact] - public async Task Use_CsvHelper_For_Response() { + readonly WireMockServer _server = WireMockServer.Start(); + + void ConfigureResponse(object expected) { + var serializer = new CsvHelperSerializer(); + + _server + .Given(Request.Create().WithPath("/").UsingGet()) + .RespondWith(Response.Create().WithBody(serializer.Serialize(expected)!).WithHeader(KnownHeaders.ContentType, ContentType.Csv)); + } + + TestObject CreateTestObject() { var expected = Fixture.Create(); expected.DateTimeValue = new DateTime( @@ -25,18 +34,16 @@ public async Task Use_CsvHelper_For_Response() { expected.DateTimeValue.Second ); - using var server = HttpServerFixture.StartServer( - (_, response) => { - var serializer = new CsvHelperSerializer(); + return expected; + } - response.ContentType = "text/csv"; - response.ContentEncoding = Encoding.UTF8; - response.OutputStream.WriteStringUtf8(serializer.Serialize(expected)!); - } - ); + [Fact] + public async Task Use_CsvHelper_For_Response() { + var expected = CreateTestObject(); - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseCsvHelper()); + ConfigureResponse(expected); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseCsvHelper()); var actual = await client.GetAsync(new RestRequest()); actual.Should().BeEquivalentTo(expected); @@ -48,49 +55,25 @@ public async Task Use_CsvHelper_For_Collection_Response() { var expected = new List(count); for (var i = 0; i < count; i++) { - var item = Fixture.Create(); - - item.DateTimeValue = new DateTime( - item.DateTimeValue.Year, - item.DateTimeValue.Month, - item.DateTimeValue.Day, - item.DateTimeValue.Hour, - item.DateTimeValue.Minute, - item.DateTimeValue.Second - ); - + var item = CreateTestObject(); expected.Add(item); } - using var server = HttpServerFixture.StartServer( - (_, response) => { - var serializer = new CsvHelperSerializer(); - - response.ContentType = "text/csv"; - response.ContentEncoding = Encoding.UTF8; - response.OutputStream.WriteStringUtf8(serializer.Serialize(expected)); - } - ); - - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseCsvHelper()); + ConfigureResponse(expected); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseCsvHelper()); var actual = await client.GetAsync>(new RestRequest()); actual.Should().BeEquivalentTo(expected); } [Fact] - public async Task DeserilizationFails_IsSuccessfull_Should_BeFalse() { - using var server = HttpServerFixture.StartServer( - (_, response) => { - response.StatusCode = (int)HttpStatusCode.OK; - response.ContentType = "text/csv"; - response.ContentEncoding = Encoding.UTF8; - response.OutputStream.WriteStringUtf8("invalid csv"); - } - ); + public async Task DeserilizationFails_IsSuccessful_Should_BeFalse() { + _server + .Given(Request.Create().WithPath("/").UsingGet()) + .RespondWith(Response.Create().WithBody("invalid csv").WithHeader(KnownHeaders.ContentType, ContentType.Csv)); - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseCsvHelper()); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseCsvHelper()); var response = await client.ExecuteAsync(new RestRequest()); @@ -100,21 +83,10 @@ public async Task DeserilizationFails_IsSuccessfull_Should_BeFalse() { [Fact] public async Task DeserilizationSucceeds_IsSuccessful_Should_BeTrue() { - var item = Fixture.Create(); - - using var server = HttpServerFixture.StartServer( - (_, response) => { - var serializer = new SystemTextJsonSerializer(); - - response.StatusCode = (int)HttpStatusCode.OK; - response.ContentType = "text/csv"; - response.ContentEncoding = Encoding.UTF8; - response.OutputStream.WriteStringUtf8(serializer.Serialize(item)!); - } - ); - - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseSystemTextJson()); + var item = CreateTestObject(); + ConfigureResponse(item); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseSystemTextJson()); var response = await client.ExecuteAsync(new RestRequest()); response.IsSuccessStatusCode.Should().BeTrue(); @@ -180,4 +152,6 @@ public void SerializedCollection_Should_Be() { "StringValue,Int32Value,DecimalValue,DoubleValue,SingleValue,DateTimeValue,TimeSpanValue;hello,32,0,0,16.5,01/20/2024 00:00:00,00:10:00;,65,89.555,0,0,08/19/2022 05:15:21,00:01:01;\"String, with comma\",0,0,20.00001,80000,01/01/0001 00:00:00,00:00:00;" ); } -} + + public void Dispose() => _server?.Dispose(); +} \ No newline at end of file diff --git a/test/RestSharp.Tests.Serializers.Csv/RestSharp.Tests.Serializers.Csv.csproj b/test/RestSharp.Tests.Serializers.Csv/RestSharp.Tests.Serializers.Csv.csproj index 4477eea34..c5305e02b 100644 --- a/test/RestSharp.Tests.Serializers.Csv/RestSharp.Tests.Serializers.Csv.csproj +++ b/test/RestSharp.Tests.Serializers.Csv/RestSharp.Tests.Serializers.Csv.csproj @@ -3,4 +3,13 @@ + + + + + + + + + diff --git a/test/RestSharp.Tests.Serializers.Json/NewtonsoftJson/IntegratedSimpleTests.cs b/test/RestSharp.Tests.Serializers.Json/NewtonsoftJson/IntegratedSimpleTests.cs index c86a4d332..573a04f52 100644 --- a/test/RestSharp.Tests.Serializers.Json/NewtonsoftJson/IntegratedSimpleTests.cs +++ b/test/RestSharp.Tests.Serializers.Json/NewtonsoftJson/IntegratedSimpleTests.cs @@ -1,32 +1,24 @@ -using System.Net; -using System.Text; using RestSharp.Serializers.NewtonsoftJson; -using RestSharp.Tests.Shared.Extensions; using RestSharp.Tests.Shared.Fixtures; namespace RestSharp.Tests.Serializers.Json.NewtonsoftJson; -public class IntegratedSimpleTests { - string _body; - - void CaptureBody(HttpListenerRequest request, HttpListenerResponse response) => _body = request.InputStream.StreamToString(); - +public sealed class IntegratedSimpleTests : IDisposable { static readonly Fixture Fixture = new(); + readonly WireMockServer _server = WireMockServer.Start(); + [Fact] public async Task Use_JsonNet_For_Requests() { - using var server = HttpServerFixture.StartServer(CaptureBody); - _body = null; + var capturer = _server.ConfigureBodyCapturer(Method.Post, false); var serializer = new JsonNetSerializer(); - - var testData = Fixture.Create(); - - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseNewtonsoftJson()); - var request = new RestRequest().AddJsonBody(testData); + var testData = Fixture.Create(); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseNewtonsoftJson()); + var request = new RestRequest().AddJsonBody(testData); await client.PostAsync(request); - var actual = serializer.Deserialize(new RestResponse(request) { Content = _body! }); + var actual = serializer.Deserialize(new RestResponse(request) { Content = capturer.Body! }); actual.Should().BeEquivalentTo(testData); } @@ -34,19 +26,11 @@ public async Task Use_JsonNet_For_Requests() { [Fact] public async Task Use_JsonNet_For_Response() { var expected = Fixture.Create(); + _server + .Given(Request.Create().WithPath("/").UsingGet()) + .RespondWith(Response.Create().WithBodyAsJson(expected)); - using var server = HttpServerFixture.StartServer( - (_, response) => { - var serializer = new JsonNetSerializer(); - - response.ContentType = "application/json"; - response.ContentEncoding = Encoding.UTF8; - response.OutputStream.WriteStringUtf8(serializer.Serialize(expected)!); - } - ); - - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseNewtonsoftJson()); - + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseNewtonsoftJson()); var actual = await client.GetAsync(new RestRequest()); actual.Should().BeEquivalentTo(expected); @@ -54,18 +38,13 @@ public async Task Use_JsonNet_For_Response() { [Fact] public async Task DeserilizationFails_IsSuccessful_Should_BeFalse() { - using var server = HttpServerFixture.StartServer( - (_, response) => { - response.StatusCode = (int)HttpStatusCode.OK; - response.ContentType = "application/json"; - response.ContentEncoding = Encoding.UTF8; - response.OutputStream.WriteStringUtf8("invalid json"); - } - ); + _server + .Given(Request.Create().WithPath("/").UsingGet()) + .RespondWith(Response.Create().WithBody("invalid json").WithHeader(KnownHeaders.ContentType, ContentType.Json)); - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseNewtonsoftJson()); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseNewtonsoftJson()); - var response = await client.ExecuteAsync(new RestRequest(), default); + var response = await client.ExecuteAsync(new RestRequest()); response.IsSuccessStatusCode.Should().BeTrue(); response.IsSuccessful.Should().BeFalse(); @@ -74,23 +53,17 @@ public async Task DeserilizationFails_IsSuccessful_Should_BeFalse() { [Fact] public async Task DeserilizationSucceeds_IsSuccessful_Should_BeTrue() { var item = Fixture.Create(); + _server + .Given(Request.Create().WithPath("/").UsingGet()) + .RespondWith(Response.Create().WithBodyAsJson(item)); - using var server = HttpServerFixture.StartServer( - (_, response) => { - var serializer = new JsonNetSerializer(); - - response.StatusCode = (int)HttpStatusCode.OK; - response.ContentType = "application/json"; - response.ContentEncoding = Encoding.UTF8; - response.OutputStream.WriteStringUtf8(serializer.Serialize(item)!); - } - ); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseNewtonsoftJson()); - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseNewtonsoftJson()); - - var response = await client.ExecuteAsync(new RestRequest(), default); + var response = await client.ExecuteAsync(new RestRequest()); response.IsSuccessStatusCode.Should().BeTrue(); response.IsSuccessful.Should().BeTrue(); } -} + + public void Dispose() => _server?.Dispose(); +} \ No newline at end of file diff --git a/test/RestSharp.Tests.Serializers.Json/NewtonsoftJson/IntegratedTests.cs b/test/RestSharp.Tests.Serializers.Json/NewtonsoftJson/IntegratedTests.cs index ce74b3a86..9fcd45865 100644 --- a/test/RestSharp.Tests.Serializers.Json/NewtonsoftJson/IntegratedTests.cs +++ b/test/RestSharp.Tests.Serializers.Json/NewtonsoftJson/IntegratedTests.cs @@ -1,25 +1,24 @@ using Newtonsoft.Json; using Newtonsoft.Json.Serialization; -using RestMockCore; using RestSharp.Serializers.NewtonsoftJson; namespace RestSharp.Tests.Serializers.Json.NewtonsoftJson; -public class IntegratedTests { +public sealed class IntegratedTests : IDisposable { static readonly Fixture Fixture = new(); - const int Port = 5001; + readonly WireMockServer _server = WireMockServer.Start(); [Fact] public async Task Use_with_GetJsonAsync() { var data = Fixture.Create(); var serialized = JsonConvert.SerializeObject(data, JsonNetSerializer.DefaultSettings); - using var server = new HttpServer(Port); - server.Config.Get("/test").Send(serialized); - server.Run(); + _server + .Given(Request.Create().WithPath("/test").UsingGet()) + .RespondWith(Response.Create().WithBody(serialized).WithHeader(KnownHeaders.ContentType, ContentType.Json)); - using var client = new RestClient($"http://localhost:{Port}", configureSerialization: cfg => cfg.UseNewtonsoftJson()); + using var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseNewtonsoftJson()); var response = await client.GetJsonAsync("/test"); @@ -34,14 +33,16 @@ public async Task Use_with_GetJsonAsync_custom_settings() { var data = Fixture.Create(); var serialized = JsonConvert.SerializeObject(data, settings); - using var server = new HttpServer(Port); - server.Config.Get("/test").Send(serialized); - server.Run(); + _server + .Given(Request.Create().WithPath("/test").UsingGet()) + .RespondWith(Response.Create().WithBody(serialized).WithHeader(KnownHeaders.ContentType, ContentType.Json)); - using var client = new RestClient($"http://localhost:{Port}", configureSerialization: cfg => cfg.UseNewtonsoftJson(settings)); + using var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseNewtonsoftJson(settings)); var response = await client.GetJsonAsync("/test"); response.Should().BeEquivalentTo(data); } + + public void Dispose() => _server?.Dispose(); } diff --git a/test/RestSharp.Tests.Serializers.Json/RestSharp.Tests.Serializers.Json.csproj b/test/RestSharp.Tests.Serializers.Json/RestSharp.Tests.Serializers.Json.csproj index 94a871e1f..ef87290b5 100644 --- a/test/RestSharp.Tests.Serializers.Json/RestSharp.Tests.Serializers.Json.csproj +++ b/test/RestSharp.Tests.Serializers.Json/RestSharp.Tests.Serializers.Json.csproj @@ -5,18 +5,12 @@ - + - - - - - - - - - - - + + + + + diff --git a/test/RestSharp.Tests.Serializers.Json/SystemTextJson/SystemTextJsonTests.cs b/test/RestSharp.Tests.Serializers.Json/SystemTextJson/SystemTextJsonTests.cs index 5d5976d48..5cfd6ac5d 100644 --- a/test/RestSharp.Tests.Serializers.Json/SystemTextJson/SystemTextJsonTests.cs +++ b/test/RestSharp.Tests.Serializers.Json/SystemTextJson/SystemTextJsonTests.cs @@ -1,51 +1,37 @@ -using System.Net; -using System.Text; using RestSharp.Serializers.Json; -using RestSharp.Tests.Shared.Extensions; using RestSharp.Tests.Shared.Fixtures; namespace RestSharp.Tests.Serializers.Json.SystemTextJson; -public class SystemTextJsonTests { +public sealed class SystemTextJsonTests : IDisposable { static readonly Fixture Fixture = new(); - string _body; - + readonly WireMockServer _server = WireMockServer.Start(); + [Fact] public async Task Use_JsonNet_For_Requests() { - using var server = HttpServerFixture.StartServer(CaptureBody); - _body = null; var serializer = new SystemTextJsonSerializer(); + var capturer = _server.ConfigureBodyCapturer(Method.Post, false); var testData = Fixture.Create(); - - var client = new RestClient(server.Url); + var client = new RestClient(_server.Url!); var request = new RestRequest().AddJsonBody(testData); await client.PostAsync(request); - var actual = serializer.Deserialize(new RestResponse(request) { Content = _body }); + var actual = serializer.Deserialize(new RestResponse(request) { Content = capturer.Body }); actual.Should().BeEquivalentTo(testData); - - void CaptureBody(HttpListenerRequest req, HttpListenerResponse response) => _body = req.InputStream.StreamToString(); } [Fact] public async Task Use_JsonNet_For_Response() { var expected = Fixture.Create(); + _server + .Given(Request.Create().WithPath("/").UsingGet()) + .RespondWith(Response.Create().WithBodyAsJson(expected)); - using var server = HttpServerFixture.StartServer( - (_, response) => { - var serializer = new SystemTextJsonSerializer(); - - response.ContentType = "application/json"; - response.ContentEncoding = Encoding.UTF8; - response.OutputStream.WriteStringUtf8(serializer.Serialize(expected)!); - } - ); - - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseSystemTextJson()); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseSystemTextJson()); var actual = await client.GetAsync(new RestRequest()); @@ -54,16 +40,11 @@ public async Task Use_JsonNet_For_Response() { [Fact] public async Task DeserilizationFails_IsSuccessful_Should_BeFalse() { - using var server = HttpServerFixture.StartServer( - (_, response) => { - response.StatusCode = (int)HttpStatusCode.OK; - response.ContentType = "application/json"; - response.ContentEncoding = Encoding.UTF8; - response.OutputStream.WriteStringUtf8("invalid json"); - } - ); + _server + .Given(Request.Create().WithPath("/").UsingGet()) + .RespondWith(Response.Create().WithBody("invalid json").WithHeader(KnownHeaders.ContentType, ContentType.Json)); - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseSystemTextJson()); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseSystemTextJson()); var response = await client.ExecuteAsync(new RestRequest()); @@ -74,23 +55,17 @@ public async Task DeserilizationFails_IsSuccessful_Should_BeFalse() { [Fact] public async Task DeserilizationSucceeds_IsSuccessful_Should_BeTrue() { var item = Fixture.Create(); + _server + .Given(Request.Create().WithPath("/").UsingGet()) + .RespondWith(Response.Create().WithBodyAsJson(item)); - using var server = HttpServerFixture.StartServer( - (_, response) => { - var serializer = new SystemTextJsonSerializer(); - - response.StatusCode = (int)HttpStatusCode.OK; - response.ContentType = "application/json"; - response.ContentEncoding = Encoding.UTF8; - response.OutputStream.WriteStringUtf8(serializer.Serialize(item)!); - } - ); - - var client = new RestClient(server.Url, configureSerialization: cfg => cfg.UseSystemTextJson()); + var client = new RestClient(_server.Url!, configureSerialization: cfg => cfg.UseSystemTextJson()); var response = await client.ExecuteAsync(new RestRequest()); response.IsSuccessStatusCode.Should().BeTrue(); response.IsSuccessful.Should().BeTrue(); } + + public void Dispose() => _server?.Dispose(); } diff --git a/test/RestSharp.Tests.Shared/Fixtures/Handlers.cs b/test/RestSharp.Tests.Shared/Fixtures/Handlers.cs index d324e881b..6aa76d27b 100644 --- a/test/RestSharp.Tests.Shared/Fixtures/Handlers.cs +++ b/test/RestSharp.Tests.Shared/Fixtures/Handlers.cs @@ -4,11 +4,6 @@ namespace RestSharp.Tests.Shared.Fixtures; public static class Handlers { - /// - /// Echoes the request input back to the output. - /// - public static void Echo(HttpListenerContext context) => context.Request.InputStream.CopyTo(context.Response.OutputStream); - /// /// T should be a class that implements methods whose names match the urls being called, and take one parameter, an /// HttpListenerContext. diff --git a/test/RestSharp.Tests.Shared/Fixtures/HttpServerFixture.cs b/test/RestSharp.Tests.Shared/Fixtures/HttpServerFixture.cs deleted file mode 100644 index d94595845..000000000 --- a/test/RestSharp.Tests.Shared/Fixtures/HttpServerFixture.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Net; - -namespace RestSharp.Tests.Shared.Fixtures; - -public sealed class HttpServerFixture : IDisposable { - public static HttpServerFixture StartServer(string url, Action handle) { - var server = new TestHttpServer(0, url, (request, response, _) => handle(request, response)); - return new HttpServerFixture(server); - } - - public static HttpServerFixture StartServer(Action handle) => StartServer("", handle); - - HttpServerFixture(TestHttpServer server) { - Url = $"http://localhost:{server.Port}"; - _server = server; - } - - public string Url { get; } - - readonly TestHttpServer _server; - - public void Dispose() => _server.Dispose(); -} \ No newline at end of file diff --git a/test/RestSharp.Tests.Integrated/Fixtures/RequestBodyCapturer.cs b/test/RestSharp.Tests.Shared/Fixtures/RequestBodyCapturer.cs similarity index 95% rename from test/RestSharp.Tests.Integrated/Fixtures/RequestBodyCapturer.cs rename to test/RestSharp.Tests.Shared/Fixtures/RequestBodyCapturer.cs index d42117797..7dc65a7e3 100644 --- a/test/RestSharp.Tests.Integrated/Fixtures/RequestBodyCapturer.cs +++ b/test/RestSharp.Tests.Shared/Fixtures/RequestBodyCapturer.cs @@ -1,6 +1,6 @@ namespace RestSharp.Tests.Integrated.Fixtures; -class RequestBodyCapturer { +public class RequestBodyCapturer { public const string Resource = "/capture"; public string? ContentType { get; private set; } diff --git a/test/RestSharp.Tests.Shared/Fixtures/TestHttpServer.cs b/test/RestSharp.Tests.Shared/Fixtures/TestHttpServer.cs deleted file mode 100644 index 25e8fd4c6..000000000 --- a/test/RestSharp.Tests.Shared/Fixtures/TestHttpServer.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.Net; -using System.Net.Sockets; -using System.Text; - -namespace RestSharp.Tests.Shared.Fixtures; - -public delegate void HandlerAction(HttpListenerRequest request, HttpListenerResponse response, Dictionary urlMap); - -public class TestHttpServer : IDisposable { - readonly HttpListener _listener; - readonly List _requestHandlers; - readonly object _requestHandlersLock = new(); - readonly CancellationTokenSource _cts = new(); - - public int Port { get; } - - public TestHttpServer(int port, string url, HandlerAction handlerAction, string hostName = "localhost") - : this(port, [new(url, handlerAction)], hostName) { } - - public TestHttpServer(int port, List handlers, string hostName = "localhost") { - _requestHandlers = handlers; - - Port = port > 0 ? port : GetRandomUnusedPort(); - - //create and start listener - _listener = new HttpListener(); - _listener.Prefixes.Add($"http://{hostName}:{Port}/"); - _listener.Start(); - - Task.Run(() => HandleRequests(_cts.Token)); - } - - static int GetRandomUnusedPort() { - var listener = new TcpListener(IPAddress.Any, 0); - listener.Start(); - var port = ((IPEndPoint)listener.LocalEndpoint).Port; - listener.Stop(); - return port; - } - - async Task HandleRequests(CancellationToken cancellationToken) { - try { - //listen for all requests - while (_listener.IsListening && !cancellationToken.IsCancellationRequested) { - //get the request - var context = await _listener.GetContextAsync(); - - try { - Dictionary parameters = null; - TestRequestHandler handler; - - lock (_requestHandlersLock) { - handler = _requestHandlers.FirstOrDefault( - h => h.TryMatchUrl(context.Request.RawUrl, context.Request.HttpMethod, out parameters) - ); - } - - string responseString = null; - - if (handler != null) { - //add the query string parameters to the pre-defined url parameters that were set from MatchesUrl() - foreach (var qsParamName in context.Request.QueryString.AllKeys) - parameters[qsParamName] = context.Request.QueryString[qsParamName]; - - try { - handler.HandlerAction(context.Request, context.Response, parameters); - } - catch (Exception ex) { - responseString = $"Exception in handler: {ex.Message}"; - context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; - } - } - else { - context.Response.ContentType("text/plain").StatusCode(404); - responseString = $"No handler provided for URL: {context.Request.RawUrl}"; - } - - context.Request.ClearContent(); - - //send the response, if there is not (if responseString is null, then the handler method should have manually set the output stream) - if (responseString != null) { - var buffer = Encoding.UTF8.GetBytes(responseString); - context.Response.ContentLength64 += buffer.Length; - await context.Response.OutputStream.WriteAsync(buffer, 0, buffer.Length, cancellationToken); - } - } - finally { - context.Response.OutputStream.Close(); - context.Response.Close(); - } - } - } - catch (HttpListenerException ex) { - //when the listener is stopped, it will throw an exception for being cancelled, so just ignore it - if (ex.Message != "The I/O operation has been aborted because of either a thread exit or an application request") throw; - } - } - - public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) { - if (disposing && _listener.IsListening) { - _listener.Stop(); - } - } -} diff --git a/test/RestSharp.Tests.Shared/Fixtures/TestHttpServerExtensions.cs b/test/RestSharp.Tests.Shared/Fixtures/TestHttpServerExtensions.cs deleted file mode 100644 index b1202c772..000000000 --- a/test/RestSharp.Tests.Shared/Fixtures/TestHttpServerExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Net; - -namespace RestSharp.Tests.Shared.Fixtures; - -public static class TestHttpServerExtensions { - static readonly Dictionary RequestContent = new(); - - internal static void ClearContent(this HttpListenerRequest request) => RequestContent.Remove(request); - - public static HttpListenerResponse ContentType(this HttpListenerResponse response, string contentType) { - response.ContentType = contentType; - return response; - } - - public static HttpListenerResponse StatusCode(this HttpListenerResponse response, int statusCode) { - response.StatusCode = statusCode; - return response; - } -} \ No newline at end of file diff --git a/test/RestSharp.Tests.Shared/Fixtures/TestRequestHandler.cs b/test/RestSharp.Tests.Shared/Fixtures/TestRequestHandler.cs deleted file mode 100644 index b01569bc9..000000000 --- a/test/RestSharp.Tests.Shared/Fixtures/TestRequestHandler.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Text.RegularExpressions; - -namespace RestSharp.Tests.Shared.Fixtures; - -public class TestRequestHandler { - readonly Regex _comparisonRegex; - - readonly List _urlParameterNames = new(); - - public TestRequestHandler(string url, string httpMethod, HandlerAction handlerAction) { - Url = url; - HttpMethod = httpMethod; - HandlerAction = handlerAction; - - _comparisonRegex = CreateComparisonRegex(url); - } - - public TestRequestHandler(string url, HandlerAction handlerAction) : this(url, null, handlerAction) { } - - string Url { get; } - string HttpMethod { get; } - internal HandlerAction HandlerAction { get; } - - Regex CreateComparisonRegex(string url) { - var regexString = Regex.Escape(url).Replace(@"\{", "{"); - - regexString += regexString.EndsWith("/") ? "?" : "/?"; - regexString = (regexString.StartsWith("/") ? "^" : "^/") + regexString; - - var regex = new Regex(@"{(.*?)}"); - - foreach (Match match in regex.Matches(regexString)) { - regexString = regexString.Replace(match.Value, @"(.*?)"); - _urlParameterNames.Add(match.Groups[1].Value); - } - - regexString += !regexString.Contains(@"\?") ? @"(\?.*)?$" : "$"; - - return new Regex(regexString); - } - - public bool TryMatchUrl(string rawUrl, string httpMethod, out Dictionary parameters) { - var match = _comparisonRegex.Match(rawUrl); - - var isMethodMatched = HttpMethod == null || HttpMethod.Split(',').Contains(httpMethod); - - if (!match.Success || !isMethodMatched) { - parameters = null; - return false; - } - - parameters = new Dictionary(); - - for (var i = 0; i < _urlParameterNames.Count; i++) parameters[_urlParameterNames[i]] = match.Groups[i + 1].Value; - return true; - } -} diff --git a/test/RestSharp.Tests.Integrated/Fixtures/WireMockExtensions.cs b/test/RestSharp.Tests.Shared/Fixtures/WireMockExtensions.cs similarity index 74% rename from test/RestSharp.Tests.Integrated/Fixtures/WireMockExtensions.cs rename to test/RestSharp.Tests.Shared/Fixtures/WireMockExtensions.cs index 26a3f85a5..922a0c207 100644 --- a/test/RestSharp.Tests.Integrated/Fixtures/WireMockExtensions.cs +++ b/test/RestSharp.Tests.Shared/Fixtures/WireMockExtensions.cs @@ -1,6 +1,11 @@ -namespace RestSharp.Tests.Integrated.Fixtures; +using RestSharp.Tests.Integrated.Fixtures; +using WireMock.RequestBuilders; +using WireMock.ResponseBuilders; +using WireMock.Server; -static class WireMockExtensions { +namespace RestSharp.Tests.Shared.Fixtures; + +public static class WireMockExtensions { public static RequestBodyCapturer ConfigureBodyCapturer(this WireMockServer server, Method method, bool usePath = true) { var capturer = new RequestBodyCapturer(); diff --git a/test/RestSharp.Tests.Shared/RestSharp.Tests.Shared.csproj b/test/RestSharp.Tests.Shared/RestSharp.Tests.Shared.csproj index 274f12fb9..06f32e8e6 100644 --- a/test/RestSharp.Tests.Shared/RestSharp.Tests.Shared.csproj +++ b/test/RestSharp.Tests.Shared/RestSharp.Tests.Shared.csproj @@ -2,4 +2,10 @@ false + + + + + +