public static void allTests() { Write("testing default values... "); Flush(); { Test.Struct1 v = new Test.Struct1(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 254); test(v.s == 16000); test(v.i == 3); test(v.l == 4); test(v.f == (float)5.1); test(v.d == 6.2); test(v.str.Equals("foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007")); test(v.c1 == Test.Color.red); test(v.c2 == Test.Color.green); test(v.c3 == Test.Color.blue); test(v.nc1 == Test.Nested.Color.red); test(v.nc2 == Test.Nested.Color.green); test(v.nc3 == Test.Nested.Color.blue); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.Struct2 v = new Test.Struct2(); test(v.boolTrue == Test.ConstBool.value); test(v.b == Test.ConstByte.value); test(v.s == Test.ConstShort.value); test(v.i == Test.ConstInt.value); test(v.l == Test.ConstLong.value); test(v.f == Test.ConstFloat.value); test(v.d == Test.ConstDouble.value); test(v.str.Equals(Test.ConstString.value)); test(v.c1 == Test.ConstColor1.value); test(v.c2 == Test.ConstColor2.value); test(v.c3 == Test.ConstColor3.value); test(v.nc1 == Test.ConstNestedColor1.value); test(v.nc2 == Test.ConstNestedColor2.value); test(v.nc3 == Test.ConstNestedColor3.value); test(v.zeroI == Test.ConstZeroI.value); test(v.zeroL == Test.ConstZeroL.value); test(v.zeroF == Test.ConstZeroF.value); test(v.zeroDotF == Test.ConstZeroDotF.value); test(v.zeroD == Test.ConstZeroD.value); test(v.zeroDotD == Test.ConstZeroDotD.value); } { Test.Struct3 v = new Test.Struct3(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); //test(v.str.Equals("foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007")); //test(v.str.Equals("foo bar")); test(v.c1 == Test.Color.red); test(v.c2 == Test.Color.green); test(v.c3 == Test.Color.blue); test(v.nc1 == Test.Nested.Color.red); test(v.nc2 == Test.Nested.Color.green); test(v.nc3 == Test.Nested.Color.blue); //test(v.noDefault == null); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.Struct4 v = new Test.Struct4(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); //test(v.str.Equals("foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007")); //test(v.str.Equals("foo bar")); test(v.c1 == Test.Color.red); test(v.c2 == Test.Color.green); test(v.c3 == Test.Color.blue); test(v.nc1 == Test.Nested.Color.red); test(v.nc2 == Test.Nested.Color.green); test(v.nc3 == Test.Nested.Color.blue); //test(v.noDefault == null); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.Base v = new Test.Base(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str.Equals("foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007")); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.Derived v = new Test.Derived(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str.Equals("foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007")); test(v.c1 == Test.Color.red); test(v.c2 == Test.Color.green); test(v.c3 == Test.Color.blue); test(v.nc1 == Test.Nested.Color.red); test(v.nc2 == Test.Nested.Color.green); test(v.nc3 == Test.Nested.Color.blue); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.BaseEx v = new Test.BaseEx(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007"); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.DerivedEx v = new Test.DerivedEx(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007"); test(v.noDefault.Equals("")); test(v.c1 == Test.Color.red); test(v.c2 == Test.Color.green); test(v.c3 == Test.Color.blue); test(v.nc1 == Test.Nested.Color.red); test(v.nc2 == Test.Nested.Color.green); test(v.nc3 == Test.Nested.Color.blue); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.ClassProperty v = new Test.ClassProperty(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str.Equals("foo bar")); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.StructProperty v = new Test.StructProperty(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.ExceptionProperty v = new Test.ExceptionProperty(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str.Equals("foo bar")); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } WriteLine("ok"); Write("testing default constructor... "); Flush(); { Test.StructNoDefaults v = new Test.StructNoDefaults(); test(v.bo == false); test(v.b == 0); test(v.s == 0); test(v.i == 0); test(v.l == 0); test(v.f == 0.0); test(v.d == 0.0); test(v.str.Equals("")); test(v.c1 == Test.Color.red); test(v.bs == null); test(v.iseq == null); test(v.st.a == 0); test(v.st2 != null); test(v.dict == null); Test.ExceptionNoDefaults e = new Test.ExceptionNoDefaults(); test(e.str.Equals("")); test(e.c1 == Test.Color.red); test(e.bs == null); test(e.st.a == 0); test(e.st2 != null); test(e.dict == null); Test.ClassNoDefaults cl = new Test.ClassNoDefaults(); test(cl.str.Equals("")); test(cl.c1 == Test.Color.red); test(cl.bs == null); test(cl.st.a == 0); test(cl.st2 != null); test(cl.dict == null); } WriteLine("ok"); }
public static Test.InitialPrx allTests(global::Test.TestHelper helper) { Ice.Communicator communicator = helper.communicator(); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::B"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::C"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::D"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::E"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::F"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::I"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::J"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::H"); // Disable Obsolete warning/error #pragma warning disable 612, 618 communicator.addObjectFactory(new MyObjectFactory(), "TestOF"); #pragma warning restore 612, 618 var output = helper.getWriter(); output.Write("testing stringToProxy... "); output.Flush(); String @ref = "initial:" + helper.getTestEndpoint(0); Ice.ObjectPrx @base = communicator.stringToProxy(@ref); test(@base != null); output.WriteLine("ok"); output.Write("testing checked cast... "); output.Flush(); var initial = Test.InitialPrxHelper.checkedCast(@base); test(initial != null); test(initial.Equals(@base)); output.WriteLine("ok"); output.Write("getting B1... "); output.Flush(); B b1 = initial.getB1(); test(b1 != null); output.WriteLine("ok"); output.Write("getting B2... "); output.Flush(); B b2 = initial.getB2(); test(b2 != null); output.WriteLine("ok"); output.Write("getting C... "); output.Flush(); C c = initial.getC(); test(c != null); output.WriteLine("ok"); output.Write("getting D... "); output.Flush(); D d = initial.getD(); test(d != null); output.WriteLine("ok"); output.Write("checking consistency... "); output.Flush(); test(b1 != b2); //test(b1 != c); //test(b1 != d); //test(b2 != c); //test(b2 != d); //test(c != d); test(b1.theB == b1); test(b1.theC == null); test(b1.theA is B); test(((B)b1.theA).theA == b1.theA); test(((B)b1.theA).theB == b1); //test(((B)b1.theA).theC is C); // Redundant -- theC is always of type C test(((C)(((B)b1.theA).theC)).theB == b1.theA); test(b1.preMarshalInvoked); test(b1.postUnmarshalInvoked); test(b1.theA.preMarshalInvoked); test(b1.theA.postUnmarshalInvoked); test(((B)b1.theA).theC.preMarshalInvoked); test(((B)b1.theA).theC.postUnmarshalInvoked); // More tests possible for b2 and d, but I think this is already // sufficient. test(b2.theA == b2); test(d.theC == null); output.WriteLine("ok"); output.Write("getting B1, B2, C, and D all at once... "); output.Flush(); B b1out; B b2out; C cout; D dout; initial.getAll(out b1out, out b2out, out cout, out dout); test(b1out != null); test(b2out != null); test(cout != null); test(dout != null); output.WriteLine("ok"); output.Write("checking consistency... "); output.Flush(); test(b1out != b2out); test(b1out.theA == b2out); test(b1out.theB == b1out); test(b1out.theC == null); test(b2out.theA == b2out); test(b2out.theB == b1out); test(b2out.theC == cout); test(cout.theB == b2out); test(dout.theA == b1out); test(dout.theB == b2out); test(dout.theC == null); test(dout.preMarshalInvoked); test(dout.postUnmarshalInvoked); test(dout.theA.preMarshalInvoked); test(dout.theA.postUnmarshalInvoked); test(dout.theB.preMarshalInvoked); test(dout.theB.postUnmarshalInvoked); test(dout.theB.theC.preMarshalInvoked); test(dout.theB.theC.postUnmarshalInvoked); output.WriteLine("ok"); output.Write("testing protected members... "); output.Flush(); EI e = (EI)initial.getE(); test(e != null && e.checkValues()); System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance; test(!typeof(E).GetField("i", flags).IsPublic&& !typeof(E).GetField("i", flags).IsPrivate); test(!typeof(E).GetField("s", flags).IsPublic&& !typeof(E).GetField("s", flags).IsPrivate); FI f = (FI)initial.getF(); test(f.checkValues()); test(((EI)f.e2).checkValues()); test(!typeof(F).GetField("e1", flags).IsPublic&& !typeof(F).GetField("e1", flags).IsPrivate); test(typeof(F).GetField("e2", flags).IsPublic&& !typeof(F).GetField("e2", flags).IsPrivate); output.WriteLine("ok"); output.Write("getting I, J and H... "); output.Flush(); var i = initial.getI(); test(i != null); var j = initial.getJ(); test(j != null); var h = initial.getH(); test(h != null); output.WriteLine("ok"); output.Write("getting K... "); { output.Flush(); var k = initial.getK(); var l = k.value as L; test(l != null); test(l.data.Equals("l")); } output.WriteLine("ok"); output.Write("testing Value as parameter... "); output.Flush(); { Ice.Value v1 = new L("l"); Ice.Value v2; Ice.Value v3 = initial.opValue(v1, out v2); test(((L)v2).data.Equals("l")); test(((L)v3).data.Equals("l")); } { L l = new L("l"); Ice.Value[] v1 = new Ice.Value[] { l }; Ice.Value[] v2; Ice.Value[] v3 = initial.opValueSeq(v1, out v2); test(((L)v2[0]).data.Equals("l")); test(((L)v3[0]).data.Equals("l")); } { L l = new L("l"); Dictionary <string, Ice.Value> v1 = new Dictionary <string, Ice.Value> { { "l", l } }; Dictionary <string, Ice.Value> v2; Dictionary <string, Ice.Value> v3 = initial.opValueMap(v1, out v2); test(((L)v2["l"]).data.Equals("l")); test(((L)v3["l"]).data.Equals("l")); } output.WriteLine("ok"); output.Write("getting D1... "); output.Flush(); D1 d1 = new D1(new A1("a1"), new A1("a2"), new A1("a3"), new A1("a4")); d1 = initial.getD1(d1); test(d1.a1.name.Equals("a1")); test(d1.a2.name.Equals("a2")); test(d1.a3.name.Equals("a3")); test(d1.a4.name.Equals("a4")); output.WriteLine("ok"); output.Write("throw EDerived... "); output.Flush(); try { initial.throwEDerived(); test(false); } catch (EDerived ederived) { test(ederived.a1.name.Equals("a1")); test(ederived.a2.name.Equals("a2")); test(ederived.a3.name.Equals("a3")); test(ederived.a4.name.Equals("a4")); } output.WriteLine("ok"); output.Write("setting G... "); output.Flush(); try { initial.setG(new G(new S("hello"), "g")); } catch (Ice.OperationNotExistException) { } output.WriteLine("ok"); output.Write("setting I... "); output.Flush(); initial.setI(i); initial.setI(j); initial.setI(h); output.WriteLine("ok"); output.Write("testing sequences..."); output.Flush(); try { Base[] inS = new Test.Base[0]; Base[] outS; Base[] retS; retS = initial.opBaseSeq(inS, out outS); inS = new Test.Base[1]; inS[0] = new Test.Base(new S(), ""); retS = initial.opBaseSeq(inS, out outS); test(retS.Length == 1 && outS.Length == 1); } catch (Ice.OperationNotExistException) { } output.WriteLine("ok"); output.Write("testing recursive type... "); output.Flush(); var top = new Test.Recursive(); var p = top; int depth = 0; try { for (; depth <= 1000; ++depth) { p.v = new Test.Recursive(); p = p.v; if ((depth < 10 && (depth % 10) == 0) || (depth < 1000 && (depth % 100) == 0) || (depth < 10000 && (depth % 1000) == 0) || (depth % 10000) == 0) { initial.setRecursive(top); } } test(!initial.supportsClassGraphDepthMax()); } catch (Ice.UnknownLocalException) { // Expected marshal exception from the server(max class graph depth reached) } catch (Ice.UnknownException) { // Expected stack overflow from the server(Java only) } initial.setRecursive(new Test.Recursive()); output.WriteLine("ok"); output.Write("testing compact ID..."); output.Flush(); try { test(initial.getCompact() != null); } catch (Ice.OperationNotExistException) { } output.WriteLine("ok"); output.Write("testing marshaled results..."); output.Flush(); b1 = initial.getMB(); test(b1 != null && b1.theB == b1); b1 = initial.getAMDMBAsync().Result; test(b1 != null && b1.theB == b1); output.WriteLine("ok"); output.Write("testing UnexpectedObjectException..."); output.Flush(); @ref = "uoet:" + helper.getTestEndpoint(0); @base = communicator.stringToProxy(@ref); test(@base != null); var uoet = Test.UnexpectedObjectExceptionTestPrxHelper.uncheckedCast(@base); test(uoet != null); try { uoet.op(); test(false); } catch (Ice.UnexpectedObjectException ex) { test(ex.type.Equals("::Test::AlsoEmpty")); test(ex.expectedType.Equals("::Test::Empty")); } catch (System.Exception ex) { output.WriteLine(ex.ToString()); test(false); } output.WriteLine("ok"); // Disable Obsolete warning/error #pragma warning disable 612, 618 output.Write("testing getting ObjectFactory..."); output.Flush(); test(communicator.findObjectFactory("TestOF") != null); output.WriteLine("ok"); output.Write("testing getting ObjectFactory as ValueFactory..."); output.Flush(); test(communicator.getValueFactoryManager().find("TestOF") != null); output.WriteLine("ok"); #pragma warning restore 612, 618 output.Write("testing partial ice_initialize..."); output.Flush(); var ib1 = new IBase(); test(ib1.id.Equals("My id")); var id1 = new IDerived(); test(id1.id.Equals("My id")); test(id1.name.Equals("My name")); var id2 = new Test.IDerived2(); test(id2.id.Equals("My id")); var i2 = new I2(); test(i2.called); var s1 = new S1(); // The struct default constructor do not call ice_initialize test(s1.id == 0); s1 = new S1(2); // The id should have the value set by ice_initialize and not 2 test(s1.id == 1); var sc1 = new SC1(); test(sc1.id.Equals("My id")); output.WriteLine("ok"); output.Write("testing class containing complex dictionary... "); output.Flush(); { var m = new Test.M(); m.v = new Dictionary <StructKey, L>(); var k1 = new StructKey(1, "1"); m.v[k1] = new L("one"); var k2 = new StructKey(2, "2"); m.v[k2] = new L("two"); Test.M m1; var m2 = initial.opM(m, out m1); test(m1.v.Count == 2); test(m2.v.Count == 2); test(m1.v[k1].data.Equals("one")); test(m2.v[k1].data.Equals("one")); test(m1.v[k2].data.Equals("two")); test(m2.v[k2].data.Equals("two")); } output.WriteLine("ok"); output.Write("testing forward declared types... "); output.Flush(); { F1 f12; F1 f11 = initial.opF1(new F1("F11"), out f12); test(f11.name.Equals("F11")); test(f12.name.Equals("F12")); F2Prx f22; F2Prx f21 = initial.opF2( F2PrxHelper.uncheckedCast(communicator.stringToProxy("F21:" + helper.getTestEndpoint())), out f22); test(f21.ice_getIdentity().name.Equals("F21")); f21.op(); test(f22.ice_getIdentity().name.Equals("F22")); if (initial.hasF3()) { F3 f32; F3 f31 = initial.opF3(new F3(new F1("F11"), F2PrxHelper.uncheckedCast(communicator.stringToProxy("F21"))), out f32); test(f31.f1.name.Equals("F11")); test(f31.f2.ice_getIdentity().name.Equals("F21")); test(f32.f1.name.Equals("F12")); test(f32.f2.ice_getIdentity().name.Equals("F22")); } } output.WriteLine("ok"); output.Write("testing sending class cycle... "); output.Flush(); { var rec = new Test.Recursive(); rec.v = rec; var acceptsCycles = initial.acceptsClassCycles(); try { initial.setCycle(rec); test(acceptsCycles); } catch (Ice.UnknownLocalException) { test(!acceptsCycles); } } output.WriteLine("ok"); return(initial); }
static public int allTests(global::Test.TestHelper helper) { var communicator = helper.communicator(); var output = helper.getWriter(); output.Write("testing serialization... "); output.Flush(); var proxy = Test.MyInterfacePrx.Parse("test", communicator); Test.MyException ex, ex2; ex = new Test.MyException(); ex.name = ""; ex.vss = new Test.ValStruct[0]; ex.vsl = new List <Test.ValStruct>(); ex.vsll = new LinkedList <Test.ValStruct>(); ex.vssk = new Stack <Test.ValStruct>(); ex.vsq = new Queue <Test.ValStruct>(); ex.isd = new Dictionary <int, string>(); ex.ivd = new Dictionary <int, Test.ValStruct>(); ex.ipd = null; ex.issd = new SortedDictionary <int, string>(); ex.optName = new Ice.Optional <string>(); ex.optInt = new Ice.Optional <int>(); ex.optValStruct = new Ice.Optional <Test.ValStruct>(); ex.optRefStruct = new Ice.Optional <Test.RefStruct>(); ex.optEnum = new Ice.Optional <Test.MyEnum>(); ex.optClass = new Ice.Optional <Test.MyClass>(); ex.optProxy = new Ice.Optional <Test.MyInterfacePrx>(); ex2 = inOut(ex, communicator); test(ex2.name.Equals("")); test(ex2.vss.Length == 0); test(ex2.vsll.Count == 0); test(ex2.vssk.Count == 0); test(ex2.vsq.Count == 0); test(ex2.isd.Count == 0); test(ex2.ivd.Count == 0); test(ex2.ipd == null); test(ex2.issd.Count == 0); test(!ex2.optName.HasValue); test(!ex2.optInt.HasValue); test(!ex2.optValStruct.HasValue); test(!ex2.optRefStruct.HasValue); test(!ex2.optEnum.HasValue); test(!ex2.optClass.HasValue); test(!ex2.optProxy.HasValue); ex.name = "MyException"; ex.b = 1; ex.s = 2; ex.i = 3; ex.l = 4; ex.vs = new Test.ValStruct(true, 1, 2, 3, 4, Test.MyEnum.enum2); ex.rs = new Test.RefStruct("RefStruct", "prop", null, proxy, new Test.MyInterfacePrx[] { proxy, null, proxy }); ex.vss = new Test.ValStruct[1]; ex.vss[0] = ex.vs; ex.vsl = new List <Test.ValStruct>(); ex.vsl.Add(ex.vs); ex.vsll = new LinkedList <Test.ValStruct>(); ex.vsll.AddLast(ex.vs); ex.vssk = new Stack <Test.ValStruct>(); ex.vssk.Push(ex.vs); ex.vsq = new Queue <Test.ValStruct>(); ex.vsq.Enqueue(ex.vs); ex.isd = new Dictionary <int, string>(); ex.isd[5] = "five"; ex.ivd = new Dictionary <int, Test.ValStruct>(); ex.ivd[1] = ex.vs; ex.ipd = new Dictionary <int, Test.MyInterfacePrx>() { { 1, proxy }, { 2, null }, { 3, proxy } }; ex.issd = new SortedDictionary <int, string>(); ex.issd[3] = "three"; ex.optName = new Ice.Optional <string>("MyException"); ex.optInt = new Ice.Optional <int>(99); ex.optValStruct = new Ice.Optional <Test.ValStruct>(ex.vs); ex.optRefStruct = new Ice.Optional <Test.RefStruct>(ex.rs); ex.optEnum = new Ice.Optional <Test.MyEnum>(Test.MyEnum.enum3); ex.optClass = new Ice.Optional <Test.MyClass>(null); ex.optProxy = new Ice.Optional <Test.MyInterfacePrx>(proxy); ex2 = inOut(ex, communicator); test(ex2.name.Equals(ex.name)); test(ex2.b == ex.b); test(ex2.s == ex.s); test(ex2.i == ex.i); test(ex2.l == ex.l); test(ex2.vs.Equals(ex.vs)); test(ex2.rs.Equals(ex.rs)); test(ex2.vss[0].Equals(ex.vs)); test(ex2.vsll.Count == 1 && ex2.vsll.Last !.Value.Equals(ex.vs)); test(ex2.vssk.Count == 1 && ex2.vssk.Peek().Equals(ex.vs)); test(ex2.vsq.Count == 1 && ex2.vsq.Peek().Equals(ex.vs)); test(ex2.isd.Count == 1 && ex2.isd[5].Equals("five")); test(ex2.ivd.Count == 1 && ex2.ivd[1].Equals(ex.vs)); test(ex2.ipd.Count == 3 && ex2.ipd[2] == null); test(ex2.issd.Count == 1 && ex2.issd[3] == "three"); test(ex2.optName.HasValue && ex2.optName.Value == "MyException"); test(ex2.optInt.HasValue && ex2.optInt.Value == 99); test(ex2.optValStruct.HasValue && ex2.optValStruct.Value.Equals(ex.vs)); test(ex2.optRefStruct.HasValue && ex2.optRefStruct.Value.Equals(ex.rs)); test(ex2.optEnum.HasValue && ex2.optEnum.Value == Test.MyEnum.enum3); test(ex2.optClass.HasValue && ex2.optClass.Value == null); test(ex2.optProxy.HasValue && ex2.optProxy.Value.Equals(proxy)); Test.RefStruct rs, rs2; rs = new Test.RefStruct(); rs.s = "RefStruct"; rs.sp = "prop"; rs.c = null; rs.p = Test.MyInterfacePrx.Parse("test", communicator); rs.seq = new Test.MyInterfacePrx[] { rs.p }; rs2 = inOut(rs, communicator); test(rs.Equals(rs2)); Test.Base b, b2; b = new Test.Base(true, 1, 2, 3, 4, Test.MyEnum.enum2); b2 = inOut(b, communicator); test(b2.bo == b.bo); test(b2.by == b.by); test(b2.sh == b.sh); test(b2.i == b.i); test(b2.l == b.l); test(b2.e == b.e); Test.MyClass c, c2; c = new Test.MyClass(true, 1, 2, 3, 4, Test.MyEnum.enum1, null, null, new Test.ValStruct(true, 1, 2, 3, 4, Test.MyEnum.enum2)); c.c = c; c.o = c; c2 = inOut(c, communicator); test(c2.bo == c.bo); test(c2.by == c.by); test(c2.sh == c.sh); test(c2.i == c.i); test(c2.l == c.l); test(c2.e == c.e); test(c2.c == c2); test(c2.o == c2); test(c2.s.Equals(c.s)); output.WriteLine("ok"); return(0); }
public static void allTests(global::Test.TestHelper helper) { var output = helper.getWriter(); output.Write("testing default values... "); output.Flush(); { Test.Base v = new Test.Base(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str.Equals("foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007")); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.Derived v = new Test.Derived(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str.Equals("foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007")); test(v.c1 == Test.Color.red); test(v.c2 == Test.Color.green); test(v.c3 == Test.Color.blue); test(v.nc1 == Test.Nested.Color.red); test(v.nc2 == Test.Nested.Color.green); test(v.nc3 == Test.Nested.Color.blue); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.BaseEx v = new Test.BaseEx(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007"); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.DerivedEx v = new Test.DerivedEx(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str == "foo \\ \"bar\n \r\n\t\u000b\f\u0007\b? \u0007 \u0007"); test(v.noDefault.Equals("")); test(v.c1 == Test.Color.red); test(v.c2 == Test.Color.green); test(v.c3 == Test.Color.blue); test(v.nc1 == Test.Nested.Color.red); test(v.nc2 == Test.Nested.Color.green); test(v.nc3 == Test.Nested.Color.blue); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.ClassProperty v = new Test.ClassProperty(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str.Equals("foo bar")); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } { Test.ExceptionProperty v = new Test.ExceptionProperty(); test(!v.boolFalse); test(v.boolTrue); test(v.b == 1); test(v.s == 2); test(v.i == 3); test(v.l == 4); test(v.f == 5.1F); test(v.d == 6.2); test(v.str.Equals("foo bar")); test(v.noDefault.Equals("")); test(v.zeroI == 0); test(v.zeroL == 0); test(v.zeroF == 0); test(v.zeroDotF == 0); test(v.zeroD == 0); test(v.zeroDotD == 0); } output.WriteLine("ok"); output.Write("testing default constructor... "); output.Flush(); { Test.ExceptionNoDefaults e = new Test.ExceptionNoDefaults(); test(e.str.Equals("")); test(e.c1 == Test.Color.red); test(e.bs == null); test(e.st.a == 0); test(e.st2 != null); test(e.dict == null); Test.ClassNoDefaults cl = new Test.ClassNoDefaults(); test(cl.str.Equals("")); test(cl.c1 == Test.Color.red); test(cl.bs == null); test(cl.st.a == 0); test(cl.st2 != null); test(cl.dict == null); } output.WriteLine("ok"); }
public static Test.InitialPrx allTests(global::Test.TestHelper helper) { Ice.Communicator communicator = helper.communicator(); var output = helper.getWriter(); var initial = InitialPrx.Parse($"initial:{helper.getTestEndpoint(0)}", communicator); output.Write("getting B1... "); output.Flush(); B b1 = initial.getB1(); test(b1 != null); output.WriteLine("ok"); output.Write("getting B2... "); output.Flush(); B b2 = initial.getB2(); test(b2 != null); output.WriteLine("ok"); output.Write("getting C... "); output.Flush(); C c = initial.getC(); test(c != null); output.WriteLine("ok"); output.Write("getting D... "); output.Flush(); D d = initial.getD(); test(d != null); output.WriteLine("ok"); output.Write("checking consistency... "); output.Flush(); test(b1 != b2); //test(b1 != c); //test(b1 != d); //test(b2 != c); //test(b2 != d); //test(c != d); test(b1.theB == b1); test(b1.theC == null); test(b1.theA is B); test(((B)b1.theA).theA == b1.theA); test(((B)b1.theA).theB == b1); //test(((B)b1.theA).theC is C); // Redundant -- theC is always of type C test(((C)(((B)b1.theA).theC)).theB == b1.theA); // More tests possible for b2 and d, but I think this is already // sufficient. test(b2.theA == b2); test(d.theC == null); output.WriteLine("ok"); output.Write("getting B1, B2, C, and D all at once... "); output.Flush(); B b1out; B b2out; C cout; D dout; initial.getAll(out b1out, out b2out, out cout, out dout); test(b1out != null); test(b2out != null); test(cout != null); test(dout != null); output.WriteLine("ok"); output.Write("checking consistency... "); output.Flush(); test(b1out != b2out); test(b1out.theA == b2out); test(b1out.theB == b1out); test(b1out.theC == null); test(b2out.theA == b2out); test(b2out.theB == b1out); test(b2out.theC == cout); test(cout.theB == b2out); test(dout.theA == b1out); test(dout.theB == b2out); test(dout.theC == null); output.WriteLine("ok"); output.Write("getting K... "); { output.Flush(); var k = initial.getK(); var l = k.value as L; test(l != null); test(l.data.Equals("l")); } output.WriteLine("ok"); output.Write("testing Value as parameter... "); output.Flush(); { Ice.Value v1 = new L("l"); Ice.Value v2; Ice.Value v3 = initial.opValue(v1, out v2); test(((L)v2).data.Equals("l")); test(((L)v3).data.Equals("l")); } { L l = new L("l"); Ice.Value[] v1 = new Ice.Value[] { l }; Ice.Value[] v2; Ice.Value[] v3 = initial.opValueSeq(v1, out v2); test(((L)v2[0]).data.Equals("l")); test(((L)v3[0]).data.Equals("l")); } { L l = new L("l"); Dictionary <string, Ice.Value> v1 = new Dictionary <string, Ice.Value> { { "l", l } }; Dictionary <string, Ice.Value> v2; Dictionary <string, Ice.Value> v3 = initial.opValueMap(v1, out v2); test(((L)v2["l"]).data.Equals("l")); test(((L)v3["l"]).data.Equals("l")); } output.WriteLine("ok"); output.Write("getting D1... "); output.Flush(); D1 d1 = new D1(new A1("a1"), new A1("a2"), new A1("a3"), new A1("a4")); d1 = initial.getD1(d1); test(d1.a1.name.Equals("a1")); test(d1.a2.name.Equals("a2")); test(d1.a3.name.Equals("a3")); test(d1.a4.name.Equals("a4")); output.WriteLine("ok"); output.Write("throw EDerived... "); output.Flush(); try { initial.throwEDerived(); test(false); } catch (EDerived ederived) { test(ederived.a1.name.Equals("a1")); test(ederived.a2.name.Equals("a2")); test(ederived.a3.name.Equals("a3")); test(ederived.a4.name.Equals("a4")); } output.WriteLine("ok"); output.Write("setting G... "); output.Flush(); try { initial.setG(new G(new S("hello"), "g")); } catch (Ice.OperationNotExistException) { } output.WriteLine("ok"); output.Write("testing sequences..."); output.Flush(); try { Base[] inS = new Test.Base[0]; Base[] outS; Base[] retS; retS = initial.opBaseSeq(inS, out outS); inS = new Test.Base[1]; inS[0] = new Test.Base(new S(), ""); retS = initial.opBaseSeq(inS, out outS); test(retS.Length == 1 && outS.Length == 1); } catch (Ice.OperationNotExistException) { } output.WriteLine("ok"); output.Write("testing recursive type... "); output.Flush(); var top = new Test.Recursive(); var p = top; int depth = 0; try { for (; depth <= 1000; ++depth) { p.v = new Test.Recursive(); p = p.v; if ((depth < 10 && (depth % 10) == 0) || (depth < 1000 && (depth % 100) == 0) || (depth < 10000 && (depth % 1000) == 0) || (depth % 10000) == 0) { initial.setRecursive(top); } } test(!initial.supportsClassGraphDepthMax()); } catch (Ice.UnknownLocalException) { // Expected marshal exception from the server(max class graph depth reached) } catch (Ice.UnknownException) { // Expected stack overflow from the server(Java only) } initial.setRecursive(new Test.Recursive()); output.WriteLine("ok"); output.Write("testing compact ID..."); output.Flush(); try { test(initial.getCompact() != null); } catch (Ice.OperationNotExistException) { } output.WriteLine("ok"); output.Write("testing marshaled results..."); output.Flush(); b1 = initial.getMB(); test(b1 != null && b1.theB == b1); b1 = initial.getAMDMBAsync().Result; test(b1 != null && b1.theB == b1); output.WriteLine("ok"); output.Write("testing UnexpectedObjectException..."); output.Flush(); var uoet = UnexpectedObjectExceptionTestPrx.Parse($"uoet:{helper.getTestEndpoint(0)}", communicator); try { uoet.op(); test(false); } catch (UnexpectedObjectException ex) { test(ex.type.Equals("::Test::AlsoEmpty")); test(ex.expectedType.Equals("::Test::Empty")); } catch (System.Exception ex) { output.WriteLine(ex.ToString()); test(false); } output.WriteLine("ok"); output.Write("testing partial ice_initialize..."); output.Flush(); var ib1 = new IBase(); test(ib1.id.Equals("My id")); var id1 = new IDerived(); test(id1.id.Equals("My id")); test(id1.name.Equals("My name")); var id2 = new Test.IDerived2(); test(id2.id.Equals("My id")); var i2 = new I2(); test(i2.called); var s1 = new S1(); // The struct default constructor do not call ice_initialize test(s1.id == 0); s1 = new S1(2); // The id should have the value set by ice_initialize and not 2 test(s1.id == 1); var sc1 = new SC1(); test(sc1.id.Equals("My id")); output.WriteLine("ok"); output.Write("testing class containing complex dictionary... "); output.Flush(); { var m = new Test.M(); m.v = new Dictionary <StructKey, L>(); var k1 = new StructKey(1, "1"); m.v[k1] = new L("one"); var k2 = new StructKey(2, "2"); m.v[k2] = new L("two"); Test.M m1; var m2 = initial.opM(m, out m1); test(m1.v.Count == 2); test(m2.v.Count == 2); test(m1.v[k1].data.Equals("one")); test(m2.v[k1].data.Equals("one")); test(m1.v[k2].data.Equals("two")); test(m2.v[k2].data.Equals("two")); } output.WriteLine("ok"); output.Write("testing forward declared types... "); output.Flush(); { F1 f12; F1 f11 = initial.opF1(new F1("F11"), out f12); test(f11.name.Equals("F11")); test(f12.name.Equals("F12")); F2Prx f22; F2Prx f21 = initial.opF2(F2Prx.Parse($"F21:{helper.getTestEndpoint()}", communicator), out f22); test(f21.Identity.name.Equals("F21")); f21.op(); test(f22.Identity.name.Equals("F22")); if (initial.hasF3()) { F3 f32; F3 f31 = initial.opF3(new F3(new F1("F11"), F2Prx.Parse("F21", communicator)), out f32); test(f31.f1.name.Equals("F11")); test(f31.f2.Identity.name.Equals("F21")); test(f32.f1.name.Equals("F12")); test(f32.f2.Identity.name.Equals("F22")); } } output.WriteLine("ok"); return(initial); }