David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 20 | using System; |
| 21 | using System.Collections.Generic; |
David Reiss | d831a21 | 2009-02-13 03:09:52 +0000 | [diff] [blame] | 22 | using System.Threading; |
| 23 | using Thrift.Collections; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 24 | using Thrift.Protocol; |
| 25 | using Thrift.Transport; |
| 26 | using Thrift.Test; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 27 | |
| 28 | namespace Test |
| 29 | { |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 30 | public class TestClient |
| 31 | { |
| 32 | private static int numIterations = 1; |
| 33 | private static string protocol = ""; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 34 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 35 | public static void Execute(string[] args) |
| 36 | { |
| 37 | try |
| 38 | { |
| 39 | string host = "localhost"; |
| 40 | int port = 9090; |
| 41 | string url = null, pipe = null; |
| 42 | int numThreads = 1; |
| 43 | bool buffered = false, framed = false, encrypted = false; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 44 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 45 | try |
| 46 | { |
| 47 | for (int i = 0; i < args.Length; i++) |
| 48 | { |
| 49 | if (args[i] == "-u") |
| 50 | { |
| 51 | url = args[++i]; |
| 52 | } |
| 53 | else if (args[i] == "-n") |
| 54 | { |
| 55 | numIterations = Convert.ToInt32(args[++i]); |
| 56 | } |
| 57 | else if (args[i] == "-pipe") // -pipe <name> |
| 58 | { |
| 59 | pipe = args[++i]; |
| 60 | Console.WriteLine("Using named pipes transport"); |
| 61 | } |
| 62 | else if (args[i].Contains("--host=")) |
| 63 | { |
| 64 | host = args[i].Substring(args[i].IndexOf("=") + 1); |
| 65 | } |
| 66 | else if (args[i].Contains("--port=")) |
| 67 | { |
| 68 | port = int.Parse(args[i].Substring(args[i].IndexOf("=")+1)); |
| 69 | } |
| 70 | else if (args[i] == "-b" || args[i] == "--buffered" || args[i] == "--transport=buffered") |
| 71 | { |
| 72 | buffered = true; |
| 73 | Console.WriteLine("Using buffered sockets"); |
| 74 | } |
| 75 | else if (args[i] == "-f" || args[i] == "--framed" || args[i] == "--transport=framed") |
| 76 | { |
| 77 | framed = true; |
| 78 | Console.WriteLine("Using framed transport"); |
| 79 | } |
| 80 | else if (args[i] == "-t") |
| 81 | { |
| 82 | numThreads = Convert.ToInt32(args[++i]); |
| 83 | } |
| 84 | else if (args[i] == "--compact" || args[i] == "--protocol=compact") |
| 85 | { |
| 86 | protocol = "compact"; |
| 87 | Console.WriteLine("Using compact protocol"); |
| 88 | } |
| 89 | else if (args[i] == "--json" || args[i] == "--protocol=json") |
| 90 | { |
| 91 | protocol = "json"; |
| 92 | Console.WriteLine("Using JSON protocol"); |
| 93 | } |
| 94 | else if (args[i] == "--ssl") |
| 95 | { |
| 96 | encrypted = true; |
| 97 | Console.WriteLine("Using encrypted transport"); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | catch (Exception e) |
| 102 | { |
| 103 | Console.WriteLine(e.StackTrace); |
| 104 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 105 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 106 | //issue tests on separate threads simultaneously |
| 107 | Thread[] threads = new Thread[numThreads]; |
| 108 | DateTime start = DateTime.Now; |
| 109 | for (int test = 0; test < numThreads; test++) |
| 110 | { |
| 111 | Thread t = new Thread(new ParameterizedThreadStart(ClientThread)); |
| 112 | threads[test] = t; |
| 113 | if (url == null) |
| 114 | { |
| 115 | // endpoint transport |
| 116 | TTransport trans = null; |
| 117 | if (pipe != null) |
| 118 | trans = new TNamedPipeClientTransport(pipe); |
| 119 | else |
| 120 | { |
| 121 | if (encrypted) |
| 122 | trans = new TTLSSocket(host, port, "../../../../../keys/client.pem"); |
| 123 | else |
| 124 | trans = new TSocket(host, port); |
| 125 | } |
Jens Geyer | c1d7943 | 2014-04-22 22:52:43 +0200 | [diff] [blame] | 126 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 127 | // layered transport |
| 128 | if (buffered) |
| 129 | trans = new TBufferedTransport(trans as TStreamTransport); |
| 130 | if (framed) |
| 131 | trans = new TFramedTransport(trans); |
Jens Geyer | c1d7943 | 2014-04-22 22:52:43 +0200 | [diff] [blame] | 132 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 133 | //ensure proper open/close of transport |
| 134 | trans.Open(); |
| 135 | trans.Close(); |
| 136 | t.Start(trans); |
| 137 | } |
| 138 | else |
| 139 | { |
| 140 | THttpClient http = new THttpClient(new Uri(url)); |
| 141 | t.Start(http); |
| 142 | } |
| 143 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 144 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 145 | for (int test = 0; test < numThreads; test++) |
| 146 | { |
| 147 | threads[test].Join(); |
| 148 | } |
| 149 | Console.Write("Total time: " + (DateTime.Now - start)); |
| 150 | } |
| 151 | catch (Exception outerEx) |
| 152 | { |
| 153 | Console.WriteLine(outerEx.Message + " ST: " + outerEx.StackTrace); |
| 154 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 155 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 156 | Console.WriteLine(); |
| 157 | Console.WriteLine(); |
| 158 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 159 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 160 | public static void ClientThread(object obj) |
| 161 | { |
| 162 | TTransport transport = (TTransport)obj; |
| 163 | for (int i = 0; i < numIterations; i++) |
| 164 | { |
| 165 | ClientTest(transport); |
| 166 | } |
| 167 | transport.Close(); |
| 168 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 169 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 170 | public static void ClientTest(TTransport transport) |
| 171 | { |
| 172 | TProtocol proto; |
| 173 | if (protocol == "compact") |
| 174 | proto = new TCompactProtocol(transport); |
| 175 | else if (protocol == "json") |
| 176 | proto = new TJSONProtocol(transport); |
| 177 | else |
| 178 | proto = new TBinaryProtocol(transport); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 179 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 180 | ThriftTest.Client client = new ThriftTest.Client(proto); |
| 181 | try |
| 182 | { |
| 183 | if (!transport.IsOpen) |
| 184 | { |
| 185 | transport.Open(); |
| 186 | } |
| 187 | } |
| 188 | catch (TTransportException ttx) |
| 189 | { |
| 190 | Console.WriteLine("Connect failed: " + ttx.Message); |
| 191 | return; |
| 192 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 193 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 194 | long start = DateTime.Now.ToFileTime(); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 195 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 196 | Console.Write("testVoid()"); |
| 197 | client.testVoid(); |
| 198 | Console.WriteLine(" = void"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 199 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 200 | Console.Write("testString(\"Test\")"); |
| 201 | string s = client.testString("Test"); |
| 202 | Console.WriteLine(" = \"" + s + "\""); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 203 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 204 | Console.Write("testByte(1)"); |
| 205 | sbyte i8 = client.testByte((sbyte)1); |
| 206 | Console.WriteLine(" = " + i8); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 207 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 208 | Console.Write("testI32(-1)"); |
| 209 | int i32 = client.testI32(-1); |
| 210 | Console.WriteLine(" = " + i32); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 211 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 212 | Console.Write("testI64(-34359738368)"); |
| 213 | long i64 = client.testI64(-34359738368); |
| 214 | Console.WriteLine(" = " + i64); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 215 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 216 | Console.Write("testDouble(5.325098235)"); |
| 217 | double dub = client.testDouble(5.325098235); |
| 218 | Console.WriteLine(" = " + dub); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 219 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 220 | Console.Write("testStruct({\"Zero\", 1, -3, -5})"); |
| 221 | Xtruct o = new Xtruct(); |
| 222 | o.String_thing = "Zero"; |
| 223 | o.Byte_thing = (sbyte)1; |
| 224 | o.I32_thing = -3; |
| 225 | o.I64_thing = -5; |
| 226 | Xtruct i = client.testStruct(o); |
| 227 | Console.WriteLine(" = {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 228 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 229 | Console.Write("testNest({1, {\"Zero\", 1, -3, -5}, 5})"); |
| 230 | Xtruct2 o2 = new Xtruct2(); |
| 231 | o2.Byte_thing = (sbyte)1; |
| 232 | o2.Struct_thing = o; |
| 233 | o2.I32_thing = 5; |
| 234 | Xtruct2 i2 = client.testNest(o2); |
| 235 | i = i2.Struct_thing; |
| 236 | Console.WriteLine(" = {" + i2.Byte_thing + ", {\"" + i.String_thing + "\", " + i.Byte_thing + ", " + i.I32_thing + ", " + i.I64_thing + "}, " + i2.I32_thing + "}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 237 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 238 | Dictionary<int, int> mapout = new Dictionary<int, int>(); |
| 239 | for (int j = 0; j < 5; j++) |
| 240 | { |
| 241 | mapout[j] = j - 10; |
| 242 | } |
| 243 | Console.Write("testMap({"); |
| 244 | bool first = true; |
| 245 | foreach (int key in mapout.Keys) |
| 246 | { |
| 247 | if (first) |
| 248 | { |
| 249 | first = false; |
| 250 | } |
| 251 | else |
| 252 | { |
| 253 | Console.Write(", "); |
| 254 | } |
| 255 | Console.Write(key + " => " + mapout[key]); |
| 256 | } |
| 257 | Console.Write("})"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 258 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 259 | Dictionary<int, int> mapin = client.testMap(mapout); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 260 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 261 | Console.Write(" = {"); |
| 262 | first = true; |
| 263 | foreach (int key in mapin.Keys) |
| 264 | { |
| 265 | if (first) |
| 266 | { |
| 267 | first = false; |
| 268 | } |
| 269 | else |
| 270 | { |
| 271 | Console.Write(", "); |
| 272 | } |
| 273 | Console.Write(key + " => " + mapin[key]); |
| 274 | } |
| 275 | Console.WriteLine("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 276 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 277 | List<int> listout = new List<int>(); |
| 278 | for (int j = -2; j < 3; j++) |
| 279 | { |
| 280 | listout.Add(j); |
| 281 | } |
| 282 | Console.Write("testList({"); |
| 283 | first = true; |
| 284 | foreach (int j in listout) |
| 285 | { |
| 286 | if (first) |
| 287 | { |
| 288 | first = false; |
| 289 | } |
| 290 | else |
| 291 | { |
| 292 | Console.Write(", "); |
| 293 | } |
| 294 | Console.Write(j); |
| 295 | } |
| 296 | Console.Write("})"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 297 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 298 | List<int> listin = client.testList(listout); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 299 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 300 | Console.Write(" = {"); |
| 301 | first = true; |
| 302 | foreach (int j in listin) |
| 303 | { |
| 304 | if (first) |
| 305 | { |
| 306 | first = false; |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | Console.Write(", "); |
| 311 | } |
| 312 | Console.Write(j); |
| 313 | } |
| 314 | Console.WriteLine("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 315 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 316 | //set |
| 317 | THashSet<int> setout = new THashSet<int>(); |
| 318 | for (int j = -2; j < 3; j++) |
| 319 | { |
| 320 | setout.Add(j); |
| 321 | } |
| 322 | Console.Write("testSet({"); |
| 323 | first = true; |
| 324 | foreach (int j in setout) |
| 325 | { |
| 326 | if (first) |
| 327 | { |
| 328 | first = false; |
| 329 | } |
| 330 | else |
| 331 | { |
| 332 | Console.Write(", "); |
| 333 | } |
| 334 | Console.Write(j); |
| 335 | } |
| 336 | Console.Write("})"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 337 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 338 | THashSet<int> setin = client.testSet(setout); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 339 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 340 | Console.Write(" = {"); |
| 341 | first = true; |
| 342 | foreach (int j in setin) |
| 343 | { |
| 344 | if (first) |
| 345 | { |
| 346 | first = false; |
| 347 | } |
| 348 | else |
| 349 | { |
| 350 | Console.Write(", "); |
| 351 | } |
| 352 | Console.Write(j); |
| 353 | } |
| 354 | Console.WriteLine("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 355 | |
| 356 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 357 | Console.Write("testEnum(ONE)"); |
| 358 | Numberz ret = client.testEnum(Numberz.ONE); |
| 359 | Console.WriteLine(" = " + ret); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 360 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 361 | Console.Write("testEnum(TWO)"); |
| 362 | ret = client.testEnum(Numberz.TWO); |
| 363 | Console.WriteLine(" = " + ret); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 364 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 365 | Console.Write("testEnum(THREE)"); |
| 366 | ret = client.testEnum(Numberz.THREE); |
| 367 | Console.WriteLine(" = " + ret); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 368 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 369 | Console.Write("testEnum(FIVE)"); |
| 370 | ret = client.testEnum(Numberz.FIVE); |
| 371 | Console.WriteLine(" = " + ret); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 372 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 373 | Console.Write("testEnum(EIGHT)"); |
| 374 | ret = client.testEnum(Numberz.EIGHT); |
| 375 | Console.WriteLine(" = " + ret); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 376 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 377 | Console.Write("testTypedef(309858235082523)"); |
| 378 | long uid = client.testTypedef(309858235082523L); |
| 379 | Console.WriteLine(" = " + uid); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 380 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 381 | Console.Write("testMapMap(1)"); |
| 382 | Dictionary<int, Dictionary<int, int>> mm = client.testMapMap(1); |
| 383 | Console.Write(" = {"); |
| 384 | foreach (int key in mm.Keys) |
| 385 | { |
| 386 | Console.Write(key + " => {"); |
| 387 | Dictionary<int, int> m2 = mm[key]; |
| 388 | foreach (int k2 in m2.Keys) |
| 389 | { |
| 390 | Console.Write(k2 + " => " + m2[k2] + ", "); |
| 391 | } |
| 392 | Console.Write("}, "); |
| 393 | } |
| 394 | Console.WriteLine("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 395 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 396 | Insanity insane = new Insanity(); |
| 397 | insane.UserMap = new Dictionary<Numberz, long>(); |
| 398 | insane.UserMap[Numberz.FIVE] = 5000L; |
| 399 | Xtruct truck = new Xtruct(); |
| 400 | truck.String_thing = "Truck"; |
| 401 | truck.Byte_thing = (sbyte)8; |
| 402 | truck.I32_thing = 8; |
| 403 | truck.I64_thing = 8; |
| 404 | insane.Xtructs = new List<Xtruct>(); |
| 405 | insane.Xtructs.Add(truck); |
| 406 | Console.Write("testInsanity()"); |
| 407 | Dictionary<long, Dictionary<Numberz, Insanity>> whoa = client.testInsanity(insane); |
| 408 | Console.Write(" = {"); |
| 409 | foreach (long key in whoa.Keys) |
| 410 | { |
| 411 | Dictionary<Numberz, Insanity> val = whoa[key]; |
| 412 | Console.Write(key + " => {"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 413 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 414 | foreach (Numberz k2 in val.Keys) |
| 415 | { |
| 416 | Insanity v2 = val[k2]; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 417 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 418 | Console.Write(k2 + " => {"); |
| 419 | Dictionary<Numberz, long> userMap = v2.UserMap; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 420 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 421 | Console.Write("{"); |
| 422 | if (userMap != null) |
| 423 | { |
| 424 | foreach (Numberz k3 in userMap.Keys) |
| 425 | { |
| 426 | Console.Write(k3 + " => " + userMap[k3] + ", "); |
| 427 | } |
| 428 | } |
| 429 | else |
| 430 | { |
| 431 | Console.Write("null"); |
| 432 | } |
| 433 | Console.Write("}, "); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 434 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 435 | List<Xtruct> xtructs = v2.Xtructs; |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 436 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 437 | Console.Write("{"); |
| 438 | if (xtructs != null) |
| 439 | { |
| 440 | foreach (Xtruct x in xtructs) |
| 441 | { |
| 442 | Console.Write("{\"" + x.String_thing + "\", " + x.Byte_thing + ", " + x.I32_thing + ", " + x.I32_thing + "}, "); |
| 443 | } |
| 444 | } |
| 445 | else |
| 446 | { |
| 447 | Console.Write("null"); |
| 448 | } |
| 449 | Console.Write("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 450 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 451 | Console.Write("}, "); |
| 452 | } |
| 453 | Console.Write("}, "); |
| 454 | } |
| 455 | Console.WriteLine("}"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 456 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 457 | sbyte arg0 = 1; |
| 458 | int arg1 = 2; |
| 459 | long arg2 = long.MaxValue; |
| 460 | Dictionary<short, string> multiDict = new Dictionary<short, string>(); |
| 461 | multiDict[1] = "one"; |
| 462 | Numberz arg4 = Numberz.FIVE; |
| 463 | long arg5 = 5000000; |
| 464 | Console.Write("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + "," + multiDict + "," + arg4 + "," + arg5 + ")"); |
| 465 | Xtruct multiResponse = client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5); |
| 466 | Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing |
| 467 | + ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n"); |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 468 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 469 | Console.WriteLine("Test Oneway(1)"); |
| 470 | client.testOneway(1); |
T Jake Luciani | 7070aaa | 2011-01-27 02:51:51 +0000 | [diff] [blame] | 471 | |
Jens Geyer | d5436f5 | 2014-10-03 19:50:38 +0200 | [diff] [blame] | 472 | Console.Write("Test Calltime()"); |
| 473 | var startt = DateTime.UtcNow; |
| 474 | for ( int k=0; k<1000; ++k ) |
| 475 | client.testVoid(); |
| 476 | Console.WriteLine(" = " + (DateTime.UtcNow - startt).TotalSeconds.ToString() + " ms a testVoid() call" ); |
| 477 | } |
| 478 | } |
David Reiss | 6319133 | 2009-01-06 19:49:22 +0000 | [diff] [blame] | 479 | } |