Skip to content

Commit 245ef57

Browse files
committed
Added unit test for AlwaysMultipartFormData_WithParameter_ExecuteTaskAsync.
1 parent ac24d7b commit 245ef57

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

RestSharp.IntegrationTests/MultipartFormDataTests.cs

+31-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
namespace RestSharp.IntegrationTests
22
{
33
using System;
4-
using System.Diagnostics;
54
using System.IO;
65
using System.Net;
76
using System.Threading;
8-
using System.Threading.Tasks;
97

108
using RestSharp.IntegrationTests.Helpers;
119

@@ -62,7 +60,7 @@ public void MultipartFormData()
6260
}
6361

6462
[Fact]
65-
public void AlwaysMultipartFormData_WithParameter()
63+
public void AlwaysMultipartFormData_WithParameter_Execute()
6664
{
6765
const string baseUrl = "http://localhost:8888/";
6866

@@ -82,7 +80,7 @@ public void AlwaysMultipartFormData_WithParameter()
8280
}
8381

8482
[Fact]
85-
public void AlwaysMultipartFormData_WithParameter_Async()
83+
public void AlwaysMultipartFormData_WithParameter_ExecuteTaskAsync()
8684
{
8785
const string baseUrl = "http://localhost:8888/";
8886

@@ -95,17 +93,42 @@ public void AlwaysMultipartFormData_WithParameter_Async()
9593
Method = Method.POST,
9694
};
9795
request.AddParameter("title", "test", ParameterType.RequestBody);
96+
97+
var task = client.ExecuteTaskAsync(request).ContinueWith(
98+
x =>
99+
{
100+
Assert.Null(x.Result.ErrorException);
101+
});
102+
103+
task.Wait();
104+
}
105+
}
106+
107+
[Fact]
108+
public void AlwaysMultipartFormData_WithParameter_ExecuteAsync()
109+
{
110+
const string baseUrl = "http://localhost:8888/";
111+
112+
using (SimpleServer.Create(baseUrl, EchoHandler))
113+
{
114+
var client = new RestClient(baseUrl);
115+
var request = new RestRequest("?json_route=/posts")
116+
{
117+
AlwaysMultipartFormData = true,
118+
Method = Method.POST,
119+
};
120+
request.AddParameter("title", "test", ParameterType.RequestBody);
98121
IRestResponse syncResponse = null;
99122

100123
using (var eventWaitHandle = new AutoResetEvent(false))
101124
{
102125
client.ExecuteAsync(
103126
request,
104127
response =>
105-
{
106-
syncResponse = response;
107-
eventWaitHandle.Set();
108-
});
128+
{
129+
syncResponse = response;
130+
eventWaitHandle.Set();
131+
});
109132

110133
eventWaitHandle.WaitOne();
111134
}

0 commit comments

Comments
 (0)