Skip to content
This repository was archived by the owner on Apr 10, 2018. It is now read-only.

Commit c832923

Browse files
committed
Revert "Added timeouts to tests"
This reverts commit 766aa38.
1 parent f99d121 commit c832923

File tree

4 files changed

+23
-47
lines changed

4 files changed

+23
-47
lines changed

RestSharp.Portable.Test/AuthenticationTests.cs

+7-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Linq;
44
using System.Net;
55
using System.Text;
6-
using System.Threading;
76
using System.Threading.Tasks;
87

98
using Org.BouncyCastle.Crypto.Parameters;
@@ -34,15 +33,14 @@ public async Task TestHttpBasicAuth(Type factoryType)
3433
{
3534
CookieContainer = new CookieContainer(),
3635
HttpClientFactory = CreateClientFactory(factoryType, false),
37-
Timeout = TimeSpan.FromSeconds(10),
3836
Credentials = new NetworkCredential(username, password),
3937
Authenticator = new HttpBasicAuthenticator(),
4038
})
4139
{
4240
var request = new RestRequest("basic-auth/{username}/{password}", Method.GET);
4341
request.AddUrlSegment("username", username);
4442
request.AddUrlSegment("password", password);
45-
var response = await client.Execute<AuthenticationResult>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
43+
var response = await client.Execute<AuthenticationResult>(request);
4644

4745
Assert.True(response.Data.Authenticated);
4846
Assert.Equal(username, response.Data.User);
@@ -61,15 +59,14 @@ public async Task TestHttpBasicAuthHidden(Type factoryType)
6159
{
6260
CookieContainer = new CookieContainer(),
6361
HttpClientFactory = CreateClientFactory(factoryType, false),
64-
Timeout = TimeSpan.FromSeconds(10),
6562
Credentials = new NetworkCredential(username, password),
6663
Authenticator = new HttpHiddenBasicAuthenticator(),
6764
})
6865
{
6966
var request = new RestRequest("hidden-basic-auth/{username}/{password}", Method.GET);
7067
request.AddUrlSegment("username", username);
7168
request.AddUrlSegment("password", password);
72-
var response = await client.Execute<AuthenticationResult>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
69+
var response = await client.Execute<AuthenticationResult>(request);
7370

7471
Assert.True(response.Data.Authenticated);
7572
Assert.Equal(username, response.Data.User);
@@ -88,15 +85,14 @@ public async Task TestHttpDigestAuth(Type factoryType)
8885
{
8986
CookieContainer = new CookieContainer(),
9087
HttpClientFactory = CreateClientFactory(factoryType, false),
91-
Timeout = TimeSpan.FromSeconds(10),
9288
Credentials = new NetworkCredential(username, password),
9389
Authenticator = new HttpDigestAuthenticator()
9490
})
9591
{
9692
var request = new RestRequest("digest-auth/auth/{username}/{password}", Method.GET);
9793
request.AddUrlSegment("username", username);
9894
request.AddUrlSegment("password", password);
99-
var response = await client.Execute<AuthenticationResult>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
95+
var response = await client.Execute<AuthenticationResult>(request);
10096

10197
Assert.True(response.Data.Authenticated);
10298
Assert.Equal(username, response.Data.User);
@@ -115,7 +111,6 @@ public async Task TestHttpDigestAuthInt(Type factoryType)
115111
{
116112
CookieContainer = new CookieContainer(),
117113
HttpClientFactory = CreateClientFactory(factoryType, false),
118-
Timeout = TimeSpan.FromSeconds(10),
119114
Credentials = new NetworkCredential(username, password),
120115
Authenticator = new HttpDigestAuthenticator()
121116
})
@@ -125,7 +120,7 @@ public async Task TestHttpDigestAuthInt(Type factoryType)
125120
request.AddUrlSegment("username", username);
126121
request.AddUrlSegment("password", password);
127122
////request.AddParameter("param1", "val1");
128-
var response = await client.Execute<AuthenticationResult>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
123+
var response = await client.Execute<AuthenticationResult>(request);
129124

130125
Assert.True(response.Data.Authenticated);
131126
Assert.Equal(username, response.Data.User);
@@ -178,7 +173,6 @@ private async Task TestOAuth10(IHttpClientFactory httpClientFactory, ISignatureP
178173
using (var client = new RestClient("http://oauthbin.com/v1/")
179174
{
180175
HttpClientFactory = httpClientFactory,
181-
Timeout = TimeSpan.FromSeconds(10)
182176
})
183177
{
184178
var consumerKey = "key";
@@ -192,7 +186,7 @@ private async Task TestOAuth10(IHttpClientFactory httpClientFactory, ISignatureP
192186

193187
{
194188
var request = new RestRequest("request-token");
195-
var response = await client.Execute(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
189+
var response = await client.Execute(request);
196190
var requestTokenResponse = Encoding.UTF8.GetString(response.RawBytes);
197191
Assert.DoesNotContain('\n', requestTokenResponse);
198192

@@ -221,7 +215,7 @@ private async Task TestOAuth10(IHttpClientFactory httpClientFactory, ISignatureP
221215

222216
{
223217
var request = new RestRequest("access-token");
224-
var response = await client.Execute(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
218+
var response = await client.Execute(request);
225219
var accessTokenResponse = Encoding.UTF8.GetString(response.RawBytes);
226220
Assert.DoesNotContain('\n', accessTokenResponse);
227221

@@ -250,7 +244,7 @@ private async Task TestOAuth10(IHttpClientFactory httpClientFactory, ISignatureP
250244
var request = new RestRequest("echo", Method.POST);
251245
request.AddParameter("one", "1");
252246
request.AddParameter("two", "2");
253-
var response = await client.Execute(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
247+
var response = await client.Execute(request);
254248
var text = Encoding.UTF8.GetString(response.RawBytes);
255249
Assert.DoesNotContain('\n', text);
256250

RestSharp.Portable.Test/IssueTests.cs

+10-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Net;
3-
using System.Threading;
43
using System.Threading.Tasks;
54

65
using RestSharp.Portable.Authenticators;
@@ -23,15 +22,14 @@ public async Task TestIssue12_Post1(Type factoryType)
2322
using (var client = new RestClient("http://httpbin.org/")
2423
{
2524
HttpClientFactory = CreateClientFactory(factoryType, false),
26-
Timeout = TimeSpan.FromSeconds(10)
2725
})
2826
{
2927
var tmp = new string('a', 70000);
3028

3129
var request = new RestRequest("post", Method.POST);
3230
request.AddParameter("param1", tmp);
3331

34-
var response = await client.Execute<HttpBinResponse>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
32+
var response = await client.Execute<HttpBinResponse>(request);
3533
Assert.NotNull(response.Data);
3634
Assert.NotNull(response.Data.Form);
3735
Assert.True(response.Data.Form.ContainsKey("param1"));
@@ -48,7 +46,6 @@ public async Task TestIssue12_Post2(Type factoryType)
4846
using (var client = new RestClient("http://httpbin.org/")
4947
{
5048
HttpClientFactory = CreateClientFactory(factoryType, false),
51-
Timeout = TimeSpan.FromSeconds(10)
5249
})
5350
{
5451
var tmp = new string('a', 70000);
@@ -57,7 +54,7 @@ public async Task TestIssue12_Post2(Type factoryType)
5754
request.AddParameter("param1", tmp);
5855
request.AddParameter("param2", "param2");
5956

60-
var response = await client.Execute<HttpBinResponse>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
57+
var response = await client.Execute<HttpBinResponse>(request);
6158
Assert.NotNull(response.Data);
6259
Assert.NotNull(response.Data.Form);
6360
Assert.True(response.Data.Form.ContainsKey("param1"));
@@ -77,7 +74,6 @@ public void TestIssue16(Type factoryType)
7774
using (var client = new RestClient("http://httpbin.org/")
7875
{
7976
HttpClientFactory = CreateClientFactory(factoryType, false),
80-
Timeout = TimeSpan.FromSeconds(10)
8177
})
8278
{
8379
var request = new RestRequest("get?a={a}");
@@ -97,16 +93,15 @@ public void TestIssue19(Type factoryType)
9793
using (var client = new RestClient("http://httpbin.org/")
9894
{
9995
HttpClientFactory = CreateClientFactory(factoryType, false),
100-
Timeout = TimeSpan.FromSeconds(10)
10196
})
10297
{
10398
var req1 = new RestRequest("post", Method.POST);
10499
req1.AddParameter("a", "value-of-a");
105-
var t1 = client.Execute<HttpBinResponse>(req1, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
100+
var t1 = client.Execute<HttpBinResponse>(req1);
106101

107102
var req2 = new RestRequest("post", Method.POST);
108103
req2.AddParameter("ab", "value-of-ab");
109-
var t2 = client.Execute<HttpBinResponse>(req2, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
104+
var t2 = client.Execute<HttpBinResponse>(req2);
110105

111106
Task.WaitAll(t1, t2);
112107

@@ -130,14 +125,13 @@ public async Task TestIssue23(Type factoryType)
130125
using (var client = new RestClient("http://httpbin.org/")
131126
{
132127
HttpClientFactory = CreateClientFactory(factoryType, false),
133-
Timeout = TimeSpan.FromSeconds(10)
134128
})
135129
{
136130
client.Authenticator = new HttpBasicAuthenticator();
137131
client.Credentials = new NetworkCredential("foo", "bar");
138132
var request = new RestRequest("post", Method.GET);
139133
request.AddJsonBody("foo");
140-
await client.Execute(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
134+
await client.Execute(request);
141135
}
142136
}
143137

@@ -151,7 +145,6 @@ public void TestIssue25(Type factoryType)
151145
using (var client = new RestClient("http://httpbin.org/")
152146
{
153147
HttpClientFactory = CreateClientFactory(factoryType, false),
154-
Timeout = TimeSpan.FromSeconds(10)
155148
})
156149
{
157150
var req1 = new RestRequest("post", Method.POST);
@@ -160,8 +153,8 @@ public void TestIssue25(Type factoryType)
160153
var req2 = new RestRequest("post", Method.POST);
161154
req2.AddParameter("ab", "value-of-ab");
162155

163-
var t1 = client.Execute<HttpBinResponse>(req1, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
164-
var t2 = client.Execute<HttpBinResponse>(req2, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
156+
var t1 = client.Execute<HttpBinResponse>(req1);
157+
var t2 = client.Execute<HttpBinResponse>(req2);
165158
Task.WaitAll(t1, t2);
166159

167160
Assert.NotNull(t1.Result.Data);
@@ -184,13 +177,12 @@ public async Task TestIssue29_CollectionModeMultiPart(Type factoryType)
184177
using (var client = new RestClient("http://httpbin.org/")
185178
{
186179
HttpClientFactory = CreateClientFactory(factoryType, false),
187-
Timeout = TimeSpan.FromSeconds(10)
188180
})
189181
{
190182
var req = new RestRequest("post", Method.POST);
191183
req.AddParameter("a", "value-of-a");
192184
req.ContentCollectionMode = ContentCollectionMode.MultiPart;
193-
var resp = await client.Execute<HttpBinResponse>(req, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
185+
var resp = await client.Execute<HttpBinResponse>(req);
194186
Assert.NotNull(resp.Data);
195187
Assert.NotNull(resp.Data.Form);
196188
Assert.True(resp.Data.Form.ContainsKey("a"));
@@ -206,13 +198,12 @@ public async Task TestIssue29_ContentTypeParameter(Type factoryType)
206198
using (var client = new RestClient("http://httpbin.org/")
207199
{
208200
HttpClientFactory = CreateClientFactory(factoryType, false),
209-
Timeout = TimeSpan.FromSeconds(10)
210201
})
211202
{
212203
var req = new RestRequest("post", Method.POST);
213204
req.AddParameter("a", "value-of-a");
214205
req.AddHeader("content-type", "application/x-www-form-urlencoded;charset=utf-8");
215-
var resp = await client.Execute<HttpBinResponse>(req, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
206+
var resp = await client.Execute<HttpBinResponse>(req);
216207
Assert.NotNull(resp.Data);
217208
Assert.NotNull(resp.Data.Form);
218209
Assert.True(resp.Data.Form.ContainsKey("a"));
@@ -228,12 +219,11 @@ public async Task TestIssue53(Type factoryType)
228219
using (var client = new RestClient("http://httpbin.org/")
229220
{
230221
HttpClientFactory = CreateClientFactory(factoryType, false),
231-
Timeout = TimeSpan.FromSeconds(10),
232222
IgnoreResponseStatusCode = true,
233223
})
234224
{
235225
var req = new RestRequest("get", Method.GET);
236-
var resp = await client.Execute<HttpBinResponse>(req, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
226+
var resp = await client.Execute<HttpBinResponse>(req);
237227
Assert.Null(resp.Data);
238228
}
239229
}

RestSharp.Portable.Test/OtherTests.cs

+4-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Linq;
33
using System.Reflection;
44
using System.Text;
5-
using System.Threading;
65
using System.Threading.Tasks;
76

87
using RestSharp.Portable.HttpClient;
@@ -24,14 +23,13 @@ public async Task TestMultipleRequests(Type factoryType)
2423
using (var client = new RestClient("http://httpbin.org/")
2524
{
2625
HttpClientFactory = CreateClientFactory(factoryType, false),
27-
Timeout = TimeSpan.FromSeconds(10),
2826
})
2927
{
3028
{
3129
var request = new RestRequest("post", Method.POST);
3230
request.AddParameter("param1", "param1");
3331

34-
var response = await client.Execute<HttpBinResponse>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
32+
var response = await client.Execute<HttpBinResponse>(request);
3533
Assert.NotNull(response.Data);
3634
Assert.NotNull(response.Data.Form);
3735
Assert.True(response.Data.Form.ContainsKey("param1"));
@@ -42,7 +40,7 @@ public async Task TestMultipleRequests(Type factoryType)
4240
var request = new RestRequest("post", Method.POST);
4341
request.AddParameter("param1", "param1+");
4442

45-
var response = await client.Execute<HttpBinResponse>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
43+
var response = await client.Execute<HttpBinResponse>(request);
4644
Assert.NotNull(response.Data);
4745
Assert.NotNull(response.Data.Form);
4846
Assert.True(response.Data.Form.ContainsKey("param1"));
@@ -59,14 +57,13 @@ public async Task TestPutRequestByteArray(Type factoryType)
5957
using (var client = new RestClient("http://httpbin.org/")
6058
{
6159
HttpClientFactory = CreateClientFactory(factoryType, false),
62-
Timeout = TimeSpan.FromSeconds(10),
6360
})
6461
{
6562
var request = new RestRequest("put", Method.PUT);
6663
var data = Encoding.UTF8.GetBytes("Hello!");
6764
request.AddParameter(string.Empty, data, ParameterType.RequestBody);
6865

69-
var response = await client.Execute<HttpBinResponse>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
66+
var response = await client.Execute<HttpBinResponse>(request);
7067
Assert.NotNull(response.Data);
7168
Assert.Equal("Hello!", response.Data.Data);
7269
}
@@ -80,7 +77,6 @@ public async Task TestPutRequestJson(Type factoryType)
8077
using (var client = new RestClient("http://httpbin.org/")
8178
{
8279
HttpClientFactory = CreateClientFactory(factoryType, false),
83-
Timeout = TimeSpan.FromSeconds(10),
8480
})
8581
{
8682
var request = new RestRequest("put", Method.PUT);
@@ -90,7 +86,7 @@ public async Task TestPutRequestJson(Type factoryType)
9086
hello = "world",
9187
});
9288

93-
var response = await client.Execute<HttpBinResponse>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
89+
var response = await client.Execute<HttpBinResponse>(request);
9490
Assert.NotNull(response.Data);
9591
Assert.NotNull(response.Data.Args);
9692
Assert.Contains("hello", response.Data.Args.Keys);
@@ -109,7 +105,6 @@ public void TestUserAgent(Type factoryType)
109105
using (var client = new RestClient("http://httpbin.org/")
110106
{
111107
HttpClientFactory = CreateClientFactory(factoryType, false),
112-
Timeout = TimeSpan.FromSeconds(10),
113108
})
114109
{
115110
Assert.NotNull(client.UserAgent);

RestSharp.Portable.Test/PostHeaderRequestTests.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Threading;
32
using System.Threading.Tasks;
43

54
using RestSharp.Portable.HttpClient;
@@ -21,14 +20,13 @@ public async Task TestRequestParameter(Type factoryType)
2120
using (var client = new RestClient("http://httpbin.org/")
2221
{
2322
HttpClientFactory = CreateClientFactory(factoryType, false),
24-
Timeout = TimeSpan.FromSeconds(10),
2523
})
2624
{
2725
var request = new RestRequest("post", Method.POST);
2826
request.AddHeader("Restsharp-Test1", "TestValue1");
2927
request.AddParameter("param1", "ParamValue1");
3028

31-
var response = await client.Execute<HttpBinResponse>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
29+
var response = await client.Execute<HttpBinResponse>(request);
3230
Assert.Equal("ParamValue1", response.Data.Form["param1"]);
3331
Assert.Equal("TestValue1", response.Data.Headers["Restsharp-Test1"]);
3432
}
@@ -42,15 +40,14 @@ public async Task TestDefaultParameter(Type factoryType)
4240
using (var client = new RestClient("http://httpbin.org/")
4341
{
4442
HttpClientFactory = CreateClientFactory(factoryType, false),
45-
Timeout = TimeSpan.FromSeconds(10),
4643
})
4744
{
4845
client.AddDefaultParameter("Restsharp-Test2", "TestValue2", ParameterType.HttpHeader);
4946

5047
var request = new RestRequest("post", Method.POST);
5148
request.AddParameter("param1", "ParamValue1");
5249

53-
var response = await client.Execute<HttpBinResponse>(request, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token);
50+
var response = await client.Execute<HttpBinResponse>(request);
5451
Assert.Equal("ParamValue1", response.Data.Form["param1"]);
5552
Assert.Equal("TestValue2", response.Data.Headers["Restsharp-Test2"]);
5653
}

0 commit comments

Comments
 (0)