public void TestAnyContainer() { System.String testString = "abcd"; OrbServices orb = OrbServices.GetSingleton(); omg.org.CORBA.TypeCode wstringTc = orb.create_wstring_tc(0); Any any = new Any(testString, wstringTc); Any result = m_testService.EchoAny(any); Assertion.AssertEquals(any.Value, result.Value); }
public void TestNilReferenceAsAny() { OrbServices orb = OrbServices.GetSingleton(); omg.org.CORBA.TypeCode nilRefTC = orb.create_tc_for_type(typeof(System.MarshalByRefObject)); Any nilRefAny = new Any(null, nilRefTC); object result = m_testService.EchoAny(nilRefAny); Assert.IsNull(result, "result not null"); Any nilRefAny2 = new Any(null, orb.create_interface_tc(String.Empty, String.Empty)); object result2 = m_testService.EchoAny(nilRefAny2); Assert.IsNull(result2, "result not null"); }
public void TestLongTypeDefAsAny() { OrbServices orb = OrbServices.GetSingleton(); int arg = 74; int result = (int)m_testService.RetrieveLongTypeDefAsAny(arg); Assert.AreEqual(arg, result, "result of RetrieveLongTypeDefAsAny"); int arg2 = 91; omg.org.CORBA.TypeCode argTC = orb.create_tc_for(arg2); omg.org.CORBA.TypeCode longTD_TC = orb.create_alias_tc("IDL:longTD:1.0", "longTD", argTC); Any any = new Any(arg2, longTD_TC); int result2 = m_testService.ExtractFromLongTypeDef(any); Assert.AreEqual(arg2, result2, "result of ExtractFromLongTypeDef"); }
public void BoxLong() { int val = 11; omg.org.CORBA.TypeCode tc = new LongTC(); Any anyContainer = new Any(val, tc); Assert.AreEqual(tc, anyContainer.Type, "wrong tc"); Assert.AreEqual(val, anyContainer.Value, "wrong val"); Assert.AreEqual(val, anyContainer.ClsValue, "wrong val"); }
public object RetrieveIdlIntArrayAsAny([IdlArray(0L, 5)] int[] arg) { // test with explicit typecode-creation IOrbServices orbServices = OrbServices.GetSingleton(); omg.org.CORBA.TypeCode arrayTC = orbServices.create_array_tc(5, orbServices.create_tc_for_type(typeof(int))); Any arrayAsAny = new Any(arg, arrayTC); return arrayAsAny; }
public Any EchoAny(Any arg) { return arg; }
public void TestPassingNullForFormalParamObjectAndAny() { object arg1 = null; object result1 = m_testService.EchoAnything(arg1); Assert.AreEqual(arg1, result1); Any any = new Any(null); Any result = m_testService.EchoAnythingContainer(any); Assert.AreEqual(any.Value, result.Value); }
public void TestSByteAsAny() { System.SByte arg = 1; System.SByte result = (System.SByte) ((System.Byte)m_testService.EchoAnything(arg)); Assert.AreEqual((System.SByte)arg, result); arg = -2; result = (System.SByte) ((System.Byte)m_testService.EchoAnything(arg)); Assert.AreEqual((System.SByte)arg, result); Any argAny = new Any(arg); Any resultAny = m_testService.EchoAnythingContainer(argAny); result = (System.SByte) ((System.Byte)resultAny.Value); Assert.AreEqual((System.SByte)arg, result); }
public void BoxSByteToOctetOutsideRange() { sbyte val = -11; omg.org.CORBA.TypeCode tc = new OctetTC(); Any anyContainer = new Any(val, tc); Assert.AreEqual(tc, anyContainer.Type, "wrong tc"); // do an unchecked cast, overflow no issue here Assert.AreEqual(unchecked((byte)val), anyContainer.Value, "wrong val"); Assert.AreEqual(unchecked((byte)val), anyContainer.ClsValue, "wrong val"); Assert.AreEqual(ReflectionHelper.ByteType, anyContainer.ClsValue.GetType(), "wrong val type"); }
public void BoxSByteToOctet() { sbyte val = 11; omg.org.CORBA.TypeCode tc = new OctetTC(); Any anyContainer = new Any(val, tc); Assert.AreEqual(tc, anyContainer.Type, "wrong tc"); Assert.AreEqual((byte)val, anyContainer.Value, "wrong val"); Assert.AreEqual((byte)val, anyContainer.ClsValue, "wrong val"); Assert.AreEqual(ReflectionHelper.ByteType, anyContainer.ClsValue.GetType(), "wrong val type"); }
public void BoxUShortFromClsOutsideRange() { short val = -11; omg.org.CORBA.TypeCode tc = new UShortTC(); Any anyContainer = new Any(val, tc); Assert.AreEqual(tc, anyContainer.Type, "wrong tc"); // do an unchecked cast, overflow no issue here Assert.AreEqual(unchecked((ushort)val), anyContainer.Value, "wrong val"); Assert.AreEqual(unchecked((ushort)val).GetType(), anyContainer.Value.GetType(), "wrong val"); Assert.AreEqual(val, anyContainer.ClsValue, "wrong val"); }
public void BoxUShortFromCls() { short val = 11; omg.org.CORBA.TypeCode tc = new UShortTC(); Any anyContainer = new Any(val, tc); Assert.AreEqual(tc, anyContainer.Type, "wrong tc"); Assert.AreEqual((ushort)val, anyContainer.Value, "wrong val"); Assert.AreEqual(((ushort)val).GetType(), anyContainer.Value.GetType(), "wrong val"); Assert.AreEqual(val, anyContainer.ClsValue, "wrong val"); }
public void BoxUShort() { ushort val = 11; omg.org.CORBA.TypeCode tc = new UShortTC(); Any anyContainer = new Any(val, tc); Assert.AreEqual(tc, anyContainer.Type, "wrong tc"); Assert.AreEqual(val, anyContainer.Value, "wrong val"); Assert.AreEqual((short)val, anyContainer.ClsValue, "wrong val"); Assert.AreEqual(ReflectionHelper.Int16Type, anyContainer.ClsValue.GetType(), "wrong val type"); }
public void BoxULongLong() { ulong val = 11; omg.org.CORBA.TypeCode tc = new ULongLongTC(); Any anyContainer = new Any(val, tc); Assert.AreEqual(tc, anyContainer.Type, "wrong tc"); Assert.AreEqual(val, anyContainer.Value, "wrong val"); Assert.AreEqual((long)val, anyContainer.ClsValue, "wrong val"); Assert.AreEqual(ReflectionHelper.Int64Type, anyContainer.ClsValue.GetType(), "wrong val type"); }
public void TestStringArrayAsAnyManualTypeCode() { string[] argArray = new string[] { "a", "b", "c" }; IOrbServices orb = OrbServices.GetSingleton(); // variant 1 with manually created type code omg.org.CORBA.TypeCode arrayTypeCode1 = orb.create_value_box_tc("RMI:[Ljava.lang.String;:071DA8BE7F971128:A0F0A4387A3BB342", "seq1_WStringValue", orb.create_tc_for_type(typeof(string))); Any arg1 = new Any(argArray, arrayTypeCode1); string[] result1 = (string[]) m_test.EchoAnything(arg1); Assertion.AssertNotNull(result1); Assertion.AssertEquals(argArray.Length, result1.Length); Assertion.AssertEquals(argArray[0], result1[0]); Assertion.AssertEquals(argArray[1], result1[1]); Assertion.AssertEquals(argArray[2], result1[2]); }
public Any EchoAnythingContainer(Any arg) { return arg; }
public void BoxBoxedValueTypeFromBoxed() { omg.org.CORBA.TypeCode tc = new ValueBoxTC("IDL:omg.org/CORBA/StringValue:1.0", "StringValue", new StringTC()); StringValue toBoxInto = new StringValue("test"); Any anyContainer = new Any(toBoxInto, tc); Assert.AreEqual(tc, anyContainer.Type, "wrong tc"); Assert.AreEqual(toBoxInto, anyContainer.ValueInternalRepresenation, "wrong val"); Assert.AreEqual(ReflectionHelper.StringValueType, anyContainer.ValueInternalRepresenation.GetType(), "wrong val type"); Assert.AreEqual(toBoxInto.Unbox(), anyContainer.Value, "wrong val"); Assert.AreEqual(ReflectionHelper.StringType, anyContainer.Value.GetType(), "wrong val type"); }
public void TestUInt64AsAny() { System.UInt64 arg = 1; System.UInt64 result = (System.UInt64) ((System.Int64)m_testService.EchoAnything(arg)); Assert.AreEqual(arg, result); arg = System.UInt64.MaxValue - 1; result = (System.UInt64) ((System.Int64)m_testService.EchoAnything(arg)); Assert.AreEqual(arg, result); Any argAny = new Any(arg); Any resultAny = m_testService.EchoAnythingContainer(argAny); result = (System.UInt64)resultAny.Value; Assert.AreEqual(arg, result); }
public void TestNonAssignableException() { try { Any any = new Any("1.0", new OctetTC()); Assert.Fail("assignement possible, but shouldn't"); } catch (BAD_PARAM bpEx) { Assert.IsTrue(bpEx.Message.StartsWith("CORBA system exception : omg.org.CORBA.BAD_PARAM [The given instance 1.0 of type"), "exception message"); } }
public void TestCustomAnyTypeCode() { System.String testString = "abcd"; OrbServices orb = OrbServices.GetSingleton(); omg.org.CORBA.TypeCode wstringTc = orb.create_wstring_tc(0); Any any = new Any(testString, wstringTc); System.String echo = (System.String)m_testService.EchoAnything(any); Assert.AreEqual(testString, echo); }
public void TestPassingWStringAsAny() { // explicit mapping OrbServices orb = OrbServices.GetSingleton(); string arg = "test"; omg.org.CORBA.TypeCode wstringTC = orb.create_wstring_tc(0); Any any = new Any(arg, wstringTC); string result = (string)m_testService.EchoAny(any); Assert.AreEqual(arg, result); // improved implicit mapping (in case of any, don't map to boxed wstringvalue. string result2 = (string)m_testService.EchoAny(arg); Assert.AreEqual(arg, result2); // check extraction on server side with implicit mapping string result3 = m_testService.ExtractFromWStringAny(arg); Assert.AreEqual(arg, result3); }
public void TestPassingStringAsAny() { // explicit mapping OrbServices orb = OrbServices.GetSingleton(); string arg = "test"; omg.org.CORBA.TypeCode stringTC = orb.create_string_tc(0); Any any = new Any(arg, stringTC); string result = (string)m_testService.EchoAny(any); Assert.AreEqual(arg, result); // check extraction on server side with explicit mapping string result3 = m_testService.ExtractFromStringAny(any); Assert.AreEqual(arg, result3); }
public void TestULongAsAny() { int arg = 74; int result = (int) m_testService.RetrieveULongAsAny(arg); Assert.AreEqual(arg, result, "wrong result of retrieveULongAsAny"); OrbServices orb = OrbServices.GetSingleton(); int arg2 = 89; omg.org.CORBA.TypeCode ulongTC = orb.create_ulong_tc(); Any any = new Any(arg2, ulongTC); int result2 = m_testService.ExtractFromULongAny(any); Assert.AreEqual(arg2, result2, "wrong result of ExtractFromULongAny"); }
public object RetrieveIdlInt3DimArray2x2x3AsAny([IdlArray(0L, 2)][IdlArrayDimension(0L, 1, 2)][IdlArrayDimension(0L, 2, 3)] System.Int32[,,] arg) { // test with explicit typecode-creation IOrbServices orbServices = OrbServices.GetSingleton(); omg.org.CORBA.TypeCode arrayTC = orbServices.create_array_tc(3, orbServices.create_tc_for_type(typeof(int))); arrayTC = orbServices.create_array_tc(2, arrayTC); arrayTC = orbServices.create_array_tc(2, arrayTC); Any arrayAsAny = new Any(arg, arrayTC); return arrayAsAny; }
public void BoxIncompatibleType() { try { byte val = 11; omg.org.CORBA.TypeCode tc = new LongTC(); Any anyContainer = new Any(val, tc); Assert.Fail("expected exception"); } catch (BAD_PARAM bp) { Assert.AreEqual(456, bp.Minor); } }