From 5fc7c113da4a687b5516ff49fbd7f4dbaaed0cc0 Mon Sep 17 00:00:00 2001 From: issafram Date: Sun, 22 Mar 2015 23:49:20 -0400 Subject: [PATCH 1/2] Attempt to fix AppVeryor issues with unit tests. Use Environment.NewLine instead of hard coding \r\n. --- .../MultipartFormDataTests.cs | 67 ++++++++++--------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/RestSharp.IntegrationTests/MultipartFormDataTests.cs b/RestSharp.IntegrationTests/MultipartFormDataTests.cs index b8778e4cd..611fb11ff 100644 --- a/RestSharp.IntegrationTests/MultipartFormDataTests.cs +++ b/RestSharp.IntegrationTests/MultipartFormDataTests.cs @@ -1,13 +1,26 @@ -using System; -using System.Net; -using NUnit.Framework; -using RestSharp.IntegrationTests.Helpers; - -namespace RestSharp.IntegrationTests +namespace RestSharp.IntegrationTests { + using System; + using System.IO; + using System.Net; + + using RestSharp.IntegrationTests.Helpers; + + using Xunit; + public class MultipartFormDataTests { - [Test] + private readonly string expected = + "-------------------------------28947758029299" + Environment.NewLine + + "Content-Disposition: form-data; name=\"foo\"" + Environment.NewLine + Environment.NewLine + + "bar" + Environment.NewLine + + "-------------------------------28947758029299" + Environment.NewLine + + "Content-Disposition: form-data; name=\"a name with spaces\"" + Environment.NewLine + Environment.NewLine + + "somedata" + Environment.NewLine + + "-------------------------------28947758029299--" + Environment.NewLine; + + + [Fact] public void MultipartFormDataAsync() { const string baseUrl = "http://localhost:8888/"; @@ -17,20 +30,19 @@ public void MultipartFormDataAsync() var client = new RestClient(baseUrl); var request = new RestRequest("/", Method.POST) { AlwaysMultipartFormData = true }; - AddParameters(request); + this.AddParameters(request); client.ExecuteAsync(request, (restResponse, handle) => { Console.WriteLine(restResponse.Content); - Assert.AreEqual(Expected, restResponse.Content); + Assert.Equal(this.expected, restResponse.Content); }); } } - [Test] + [Fact] public void MultipartFormData() { - //const string baseUrl = "http://localhost:8888/"; const string baseUrl = "http://localhost:8888/"; using (SimpleServer.Create(baseUrl, EchoHandler)) @@ -38,38 +50,27 @@ public void MultipartFormData() var client = new RestClient(baseUrl); var request = new RestRequest("/", Method.POST) { AlwaysMultipartFormData = true }; - AddParameters(request); + this.AddParameters(request); var response = client.Execute(request); - //Console.WriteLine(response.Content); - - Assert.AreEqual(Expected, response.Content); + Assert.Equal(this.expected, response.Content); } } - private void AddParameters(RestRequest request) - { - request.AddParameter("foo", "bar"); - request.AddParameter("a name with spaces", "somedata"); - } - - private const string Expected = - "-------------------------------28947758029299\r\n" + - "Content-Disposition: form-data; name=\"foo\"\r\n\r\n" + - "bar\r\n" + - "-------------------------------28947758029299\r\n" + - "Content-Disposition: form-data; name=\"a name with spaces\"\r\n\r\n" + - "somedata\r\n" + - "-------------------------------28947758029299--\r\n"; - - private void EchoHandler(HttpListenerContext obj) + private static void EchoHandler(HttpListenerContext obj) { obj.Response.StatusCode = 200; - var streamReader = new System.IO.StreamReader(obj.Request.InputStream); + var streamReader = new StreamReader(obj.Request.InputStream); obj.Response.OutputStream.WriteStringUtf8(streamReader.ReadToEnd()); } + + private void AddParameters(RestRequest request) + { + request.AddParameter("foo", "bar"); + request.AddParameter("a name with spaces", "somedata"); + } } -} +} \ No newline at end of file From b7c094ac305cb9aff0d581e4fc40e21bae8563a6 Mon Sep 17 00:00:00 2001 From: issafram Date: Sun, 22 Mar 2015 23:57:52 -0400 Subject: [PATCH 2/2] Remove NUnit from solution. --- RestSharp.IntegrationTests/RestSharp.IntegrationTests.csproj | 3 --- RestSharp.IntegrationTests/packages.config | 1 - RestSharp.Net4/RestSharp.Net4.csproj | 3 --- RestSharp.Net4/packages.config | 1 - 4 files changed, 8 deletions(-) diff --git a/RestSharp.IntegrationTests/RestSharp.IntegrationTests.csproj b/RestSharp.IntegrationTests/RestSharp.IntegrationTests.csproj index ed32cde0b..e40d4ddae 100644 --- a/RestSharp.IntegrationTests/RestSharp.IntegrationTests.csproj +++ b/RestSharp.IntegrationTests/RestSharp.IntegrationTests.csproj @@ -62,9 +62,6 @@ AllRules.ruleset - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - 3.5 diff --git a/RestSharp.IntegrationTests/packages.config b/RestSharp.IntegrationTests/packages.config index 97c804658..998913d1d 100644 --- a/RestSharp.IntegrationTests/packages.config +++ b/RestSharp.IntegrationTests/packages.config @@ -1,6 +1,5 @@  - \ No newline at end of file diff --git a/RestSharp.Net4/RestSharp.Net4.csproj b/RestSharp.Net4/RestSharp.Net4.csproj index 461f443b0..4447027bc 100644 --- a/RestSharp.Net4/RestSharp.Net4.csproj +++ b/RestSharp.Net4/RestSharp.Net4.csproj @@ -38,9 +38,6 @@ true - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - diff --git a/RestSharp.Net4/packages.config b/RestSharp.Net4/packages.config index 967502dc8..6b8deb9c9 100644 --- a/RestSharp.Net4/packages.config +++ b/RestSharp.Net4/packages.config @@ -1,4 +1,3 @@  - \ No newline at end of file