Github user Jens-G commented on a diff in the pull request:
https://github.com/apache/thrift/pull/562#discussion_r35482999
--- Diff: lib/csharp/test/TestIOStreamServer/TestIOStreamClient.cs ---
@@ -0,0 +1,425 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Diagnostics;
+using System.Collections.Generic;
+using Thrift;
+using Thrift.Collections;
+using Thrift.Transport;
+using Thrift.Protocol;
+using Thrift.Test;
+using Test;
+
+namespace TestIOStreamClient
+{
+ [TestClass]
+ public class TestIOStreamClient
+ {
+ private static string serverFileName =
"..\\..\\..\\TestStreamServer\\bin\\Debug\\TestStreamServer.exe";
+ private static string protocolName = "binary";
+ private static TProtocolFactory protocolFactory = new
TBinaryProtocol.Factory();
+ private static TStreamTransport transport;
+ private static Process other;
+ private static ThriftTest.Client client;
+
+ [TestInitialize]
+ public void setUp()
+ {
+ var server = new ProcessStartInfo();
+ server.FileName = serverFileName;
+ server.Arguments = "--" + protocolName;
+ server.UseShellExecute = false;
+ server.RedirectStandardInput = true;
+ server.RedirectStandardOutput = true;
+
+ other = Process.Start(server);
+
+ Console.SetIn(other.StandardOutput);
+ Console.SetOut(other.StandardInput);
+
+ transport = new
TStreamTransport(other.StandardOutput.BaseStream,
other.StandardInput.BaseStream);
+ TProtocol protocol = protocolFactory.GetProtocol(transport);
+ client = new ThriftTest.Client(protocol);
+
+ transport.Open();
+ }
+
+ [TestCleanup]
+ public void tearDown()
+ {
+ transport.Close();
+ //close server
+ other.Kill();//kills process
+ other.Close();//cleans up
+ }
+
+ [TestMethod]
+ public void testVoid()
+ {
+ client.testVoid();
+ }
+
+ [TestMethod]
+ public void testString()
+ {
+ string s = client.testString("Test");
+ Assert.AreEqual("Test", s);
+ }
+
+ [TestMethod]
+ public void testByte()
+ {
+ sbyte b = client.testByte((sbyte)1);
+ Assert.AreEqual(1, b);
+ }
+
+ [TestMethod]
+ public void testI32()
+ {
+ int i = client.testI32(-1);
+ Assert.AreEqual(-1, i);
+ }
+
+ [TestMethod]
+ public void testI64()
+ {
+ long l = client.testI64(-34359738368);
+ Assert.AreEqual(-34359738368, l);
+ }
+
+ [TestMethod]
+ public void testDouble()
+ {
+ double d = client.testDouble(5.325098235);
+ Assert.AreEqual(5.325098235, d);
+ }
+
+ [TestMethod]
+ public void testBinary()
+ {
+ byte[] binOut = TestClient.PrepareTestData(true);
+ byte[] binIn = client.testBinary(binOut);
+ Assert.AreEqual(binOut.Length, binIn.Length);
+ for (int ofs = 0; ofs < binIn.Length; ++ofs)
+ Assert.AreEqual(binOut[ofs], binIn[ofs]);
+ }
+
+ [TestMethod]
+ public void testStruct()
+ {
+ Xtruct o = new Xtruct();
+ o.String_thing = "Zero";
+ o.Byte_thing = (sbyte)1;
+ o.I32_thing = -3;
+ o.I64_thing = -5;
+ Xtruct i = client.testStruct(o);
+ Assert.AreEqual(o.String_thing, i.String_thing);
+ Assert.AreEqual(o.Byte_thing, i.Byte_thing);
+ Assert.AreEqual(o.I32_thing, i.I32_thing);
+ Assert.AreEqual(o.I64_thing, i.I64_thing);
+ }
+
+ [TestMethod]
+ public void testNest()
+ {
+ Xtruct o = new Xtruct();
+ o.String_thing = "Zero";
+ o.Byte_thing = (sbyte)1;
+ o.I32_thing = -3;
+ o.I64_thing = -5;
+
+ Xtruct2 o2 = new Xtruct2();
+ o2.Byte_thing = (sbyte)1;
+ o2.Struct_thing = o;
+ o2.I32_thing = 5;
+ Xtruct2 i2 = client.testNest(o2);
+ Assert.AreEqual(o2.Byte_thing, i2.Byte_thing);
+ Assert.AreEqual(o2.Struct_thing.String_thing,
i2.Struct_thing.String_thing);
+ Assert.AreEqual(o2.Struct_thing.Byte_thing,
i2.Struct_thing.Byte_thing);
+ Assert.AreEqual(o2.Struct_thing.I32_thing,
i2.Struct_thing.I32_thing);
+ Assert.AreEqual(o2.Struct_thing.I64_thing,
i2.Struct_thing.I64_thing);
+ Assert.AreEqual(o2.I32_thing, i2.I32_thing);
+ }
+
+ [TestMethod]
+ public void testMap()
+ {
+ Dictionary<int, int> mapout = new Dictionary<int, int>();
+ for (int j = 0; j < 5; j++)
+ {
+ mapout[j] = j - 10;
+ }
+
+ Dictionary<int, int> mapin = client.testMap(mapout);
+ Assert.AreEqual(mapout.Count, mapin.Count);
+ foreach (KeyValuePair<int, int> pair in mapout)
+ {
+ Assert.AreEqual(pair.Value, mapin[pair.Key]);
+ }
+ }
+
+ [TestMethod]
+ public void testList()
+ {
+ List<int> listout = new List<int>();
+ for (int j = -2; j < 3; j++)
+ {
+ listout.Add(j);
+ }
+
+ List<int> listin = client.testList(listout);
+
+ Assert.AreEqual(listout.Count, listin.Count);
+ foreach (int i in listout)
+ {
+ Assert.IsTrue(listin.Contains(i));
+ }
+ }
+
+ [TestMethod]
+ public void testSet()
+ {
+ THashSet<int> setout = new THashSet<int>();
+ for (int j = -2; j < 3; j++)
+ {
+ setout.Add(j);
+ }
+
+ THashSet<int> setin = client.testSet(setout);
+
+ Assert.AreEqual(setout.Count, setin.Count);
+ foreach (int i in setout)
+ {
+ Assert.IsTrue(setin.Contains(i));
+ }
+ }
+
+ [TestMethod]
+ public void testEnum()
+ {
--- End diff --
I'd rather like the test being included into the existing standard
ThriftTest test client, instead of writing a duplicated one. Having two of them
does not make much sense, do you agree?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---