summaryrefslogtreecommitdiff
path: root/test/netstd/Client/TestClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'test/netstd/Client/TestClient.cs')
-rw-r--r--test/netstd/Client/TestClient.cs103
1 files changed, 13 insertions, 90 deletions
diff --git a/test/netstd/Client/TestClient.cs b/test/netstd/Client/TestClient.cs
index 2d18cf1f9..38bccf1f5 100644
--- a/test/netstd/Client/TestClient.cs
+++ b/test/netstd/Client/TestClient.cs
@@ -17,6 +17,7 @@
#pragma warning disable IDE0066 // switch expression
#pragma warning disable IDE0057 // substring
+#pragma warning disable CS1998 // no await in async method
using System;
using System.Collections.Generic;
@@ -322,7 +323,7 @@ namespace ThriftTest
numIterations = param.numIterations;
}
- public void Execute()
+ public async Task Execute()
{
if (done)
{
@@ -335,7 +336,7 @@ namespace ThriftTest
try
{
if (!transport.IsOpen)
- transport.OpenAsync(MakeTimeoutToken()).GetAwaiter().GetResult();
+ await transport.OpenAsync(MakeTimeoutToken());
}
catch (TTransportException ex)
{
@@ -356,7 +357,7 @@ namespace ThriftTest
try
{
- ReturnCode |= ExecuteClientTest(client).GetAwaiter().GetResult(); ;
+ ReturnCode |= await ExecuteClientTest(client);
}
catch (Exception ex)
{
@@ -393,7 +394,7 @@ namespace ThriftTest
Console.WriteLine();
}
- public static int Execute(List<string> args)
+ public static async Task<int> Execute(List<string> args)
{
try
{
@@ -414,15 +415,9 @@ namespace ThriftTest
var tests = Enumerable.Range(0, param.numThreads).Select(_ => new ClientTest(param)).ToArray();
//issue tests on separate threads simultaneously
- var threads = tests.Select(test => new Task(test.Execute)).ToArray();
var start = DateTime.Now;
- foreach (var t in threads)
- {
- t.Start();
- }
-
- Task.WaitAll(threads);
-
+ var tasks = tests.Select(test => test.Execute()).ToArray();
+ Task.WaitAll(tasks);
Console.WriteLine("Total time: " + (DateTime.Now - start));
Console.WriteLine();
return tests.Select(t => t.ReturnCode).Aggregate((r1, r2) => r1 | r2);
@@ -660,37 +655,13 @@ namespace ThriftTest
mapout[j] = j - 10;
}
Console.Write("testMap({");
- var first = true;
- foreach (var key in mapout.Keys)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(key + " => " + mapout[key]);
- }
+ Console.Write(string.Join(", ", mapout.Select((pair) => { return pair.Key + " => " + pair.Value; })));
Console.Write("})");
var mapin = await client.testMap(mapout, MakeTimeoutToken());
Console.Write(" = {");
- first = true;
- foreach (var key in mapin.Keys)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(key + " => " + mapin[key]);
- }
+ Console.Write(string.Join(", ", mapin.Select((pair) => { return pair.Key + " => " + pair.Value; })));
Console.WriteLine("}");
// TODO: Validate received message
@@ -700,37 +671,13 @@ namespace ThriftTest
listout.Add(j);
}
Console.Write("testList({");
- first = true;
- foreach (var j in listout)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(j);
- }
+ Console.Write(string.Join(", ", listout));
Console.Write("})");
var listin = await client.testList(listout, MakeTimeoutToken());
Console.Write(" = {");
- first = true;
- foreach (var j in listin)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(j);
- }
+ Console.Write(string.Join(", ", listin));
Console.WriteLine("}");
//set
@@ -741,37 +688,13 @@ namespace ThriftTest
setout.Add(j);
}
Console.Write("testSet({");
- first = true;
- foreach (int j in setout)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(j);
- }
+ Console.Write(string.Join(", ", setout));
Console.Write("})");
var setin = await client.testSet(setout, MakeTimeoutToken());
Console.Write(" = {");
- first = true;
- foreach (int j in setin)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- Console.Write(", ");
- }
- Console.Write(j);
- }
+ Console.Write(string.Join(", ", setin));
Console.WriteLine("}");