Add a test client and server for C#.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665633 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/csharp/CSharpClient.cs b/test/csharp/CSharpClient.cs
new file mode 100644
index 0000000..2cb6a83
--- /dev/null
+++ b/test/csharp/CSharpClient.cs
@@ -0,0 +1,68 @@
+using System;
+using Thrift;
+using Thrift.Protocol;
+using Thrift.Server;
+using Thrift.Transport;
+
+
+namespace CSharpTutorial
+{
+ public class CSharpClient
+ {
+ public static void Main()
+ {
+ try
+ {
+ TTransport transport = new TSocket("localhost", 9090);
+ TProtocol protocol = new TBinaryProtocol(transport);
+ Calculator.Client client = new Calculator.Client(protocol);
+
+ transport.Open();
+
+ client.ping();
+ Console.WriteLine("ping()");
+
+ int sum = client.add(1, 1);
+ Console.WriteLine("1+1={0}", sum);
+
+ Work work = new Work();
+
+ work.op = Operation.DIVIDE;
+ work.num1 = 1;
+ work.num2 = 0;
+ try
+ {
+ int quotient = client.calculate(1, work);
+ Console.WriteLine("Whoa we can divide by 0");
+ }
+ catch (InvalidOperation io)
+ {
+ Console.WriteLine("Invalid operation: " + io.why);
+ }
+
+ work.op = Operation.SUBTRACT;
+ work.num1 = 15;
+ work.num2 = 10;
+ try
+ {
+ int diff = client.calculate(1, work);
+ Console.WriteLine("15-10={0}", diff);
+ }
+ catch (InvalidOperation io)
+ {
+ Console.WriteLine("Invalid operation: " + io.why);
+ }
+
+ SharedStruct log = client.getStruct(1);
+ Console.WriteLine("Check log: {0}", log.value);
+
+ transport.Close();
+ }
+ catch (TApplicationException x)
+ {
+ Console.WriteLine(x.StackTrace);
+ }
+
+ }
+ }
+}
\ No newline at end of file