Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 869f78e

Browse files
committed
cleanup tests
1 parent 4d71be5 commit 869f78e

File tree

1 file changed

+8
-37
lines changed

1 file changed

+8
-37
lines changed

tests/Titanium.Web.Proxy.IntegrationTests/NestedProxyTests.cs

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ public async Task Nested_Proxy_Farm_Without_Connection_Cache_Should_Not_Hang()
114114
proxy1.EnableConnectionPool = false;
115115
var proxy2 = proxies2[rnd.Next() % proxies2.Count];
116116

117-
var explicitEndpoint = proxy1.ProxyEndPoints.OfType<ExplicitProxyEndPoint>().First();
118-
explicitEndpoint.BeforeTunnelConnectRequest += (_, e) =>
117+
proxy1.GetCustomUpStreamProxyFunc += async (_) =>
119118
{
120-
e.CustomUpStreamProxy = new ExternalProxy()
119+
var proxy = new ExternalProxy()
121120
{
122121
HostName = "localhost",
123122
Port = proxy2.ProxyEndPoints[0].Port,
@@ -126,21 +125,7 @@ public async Task Nested_Proxy_Farm_Without_Connection_Cache_Should_Not_Hang()
126125
Password = "test_password"
127126
};
128127

129-
return Task.CompletedTask;
130-
};
131-
132-
proxy1.BeforeRequest += (_, e) =>
133-
{
134-
e.CustomUpStreamProxy = new ExternalProxy()
135-
{
136-
HostName = "localhost",
137-
Port = proxy2.ProxyEndPoints[0].Port,
138-
ProxyType = ExternalProxyType.Http,
139-
UserName = "test_user",
140-
Password = "test_password"
141-
};
142-
143-
return Task.CompletedTask;
128+
return await Task.FromResult(proxy);
144129
};
145130

146131
proxies1.Add(proxy1);
@@ -164,7 +149,7 @@ await client.PostAsync(new Uri(server.ListeningHttpsUrl),
164149
new StringContent("hello server. I am a client."));
165150

166151
}
167-
//if error is thrown because of server overloading its okay.
152+
//if error is thrown because of server getting overloaded its okay.
168153
//But client.PostAsync should'nt hang in all cases.
169154
catch { }
170155
});
@@ -212,24 +197,10 @@ public async Task Nested_Proxy_Farm_With_Connection_Cache_Should_Not_Hang()
212197
{
213198
var proxy1 = testSuite.GetProxy();
214199
var proxy2 = proxies2[rnd.Next() % proxies2.Count];
215-
var explicitEndpoint = proxy1.ProxyEndPoints.OfType<ExplicitProxyEndPoint>().First();
216-
explicitEndpoint.BeforeTunnelConnectRequest += (_, e) =>
217-
{
218-
e.CustomUpStreamProxy = new ExternalProxy()
219-
{
220-
HostName = "localhost",
221-
Port = proxy2.ProxyEndPoints[0].Port,
222-
ProxyType = ExternalProxyType.Http,
223-
UserName = "test_user",
224-
Password = "test_password"
225-
};
226-
227-
return Task.CompletedTask;
228-
};
229200

230-
proxy1.BeforeRequest += (_, e) =>
201+
proxy1.GetCustomUpStreamProxyFunc += async (_) =>
231202
{
232-
e.CustomUpStreamProxy = new ExternalProxy()
203+
var proxy = new ExternalProxy()
233204
{
234205
HostName = "localhost",
235206
Port = proxy2.ProxyEndPoints[0].Port,
@@ -238,7 +209,7 @@ public async Task Nested_Proxy_Farm_With_Connection_Cache_Should_Not_Hang()
238209
Password = "test_password"
239210
};
240211

241-
return Task.CompletedTask;
212+
return await Task.FromResult(proxy);
242213
};
243214

244215
proxies1.Add(proxy1);
@@ -261,7 +232,7 @@ public async Task Nested_Proxy_Farm_With_Connection_Cache_Should_Not_Hang()
261232
await client.PostAsync(new Uri(server.ListeningHttpsUrl),
262233
new StringContent("hello server. I am a client."));
263234
}
264-
//if error is thrown because of server overloading its okay.
235+
//if error is thrown because of server getting overloaded its okay.
265236
//But client.PostAsync should'nt hang in all cases.
266237
catch { }
267238
});

0 commit comments

Comments
 (0)