Exemplo n.º 1
0
 public void Setup()
 {
     m_tc = new LongTC();
 }
Exemplo n.º 2
0
 public void TestEquivalent()
 {
     ULongTC other = new ULongTC();
     Assert.IsTrue(m_tc.equivalent(other), "not equal");
     LongTC other2 = new LongTC();
     Assert.IsTrue(!m_tc.equivalent(other2), "equal but shoudln't");
 }
        public void TestGenerateSpecialNameRepId()
        {
            string name = "TestUnionGenForTypeCodeType3";
            string typeName = "Ch.Elca.Iiop.Tests." + name;
            string repId = "IDL:Ch/Elca/Iiop/Tests/Special_TestUnionGenForTypeCodeType3:1.0";

            UnionSwitchCase s1 = new UnionSwitchCase((int)0, "val_0", new LongTC());
            UnionSwitchCase s2 = new UnionSwitchCase((int)1, "val_1", new FloatTC());
            TypeCodeImpl discrTC = new LongTC();
            UnionTC tc = new UnionTC(repId, name, discrTC, 0,
                                     new UnionSwitchCase[] { s1, s2 });
            Type res = m_gen.CreateOrGetType(typeName, tc);
            Assert.NotNull(res);
            Assert.AreEqual(typeName, res.FullName, "type name");
            Assert.AreEqual(repId, Repository.GetRepositoryID(res), "rep id");
        }
        public void TestGenerate()
        {
            string name = "TestUnionGenForTypeCodeType";
            string typeName = "Ch.Elca.Iiop.Tests." + name;
            string repId = "IDL:Ch/Elca/Iiop/Tests/TestUnionGenForTypeCodeType:1.0";

            UnionSwitchCase s1 = new UnionSwitchCase((int)0, "val_0", new LongTC());
            UnionSwitchCase s2 = new UnionSwitchCase((int)1, "val_1", new FloatTC());
            TypeCodeImpl discrTC = new LongTC();
            UnionTC tc = new UnionTC(repId, name, discrTC, 0,
                                     new UnionSwitchCase[] { s1, s2 });
            Type res = m_gen.CreateOrGetType(typeName, tc);
            Assert.NotNull(res);
            Assert.AreEqual(typeName, res.FullName, "type name");
            Assert.AreEqual(repId, Repository.GetRepositoryID(res), "rep id");

            MethodInfo getFieldForDiscrMethod =
                res.GetMethod(UnionGenerationHelper.GET_FIELD_FOR_DISCR_METHOD, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            Assert.NotNull(getFieldForDiscrMethod, "get field for Discr method");
            FieldInfo fieldForDiscr1 = (FieldInfo)
                getFieldForDiscrMethod.Invoke(null, new object[] { s1.DiscriminatorValue });
            FieldInfo fieldForDiscr2 = (FieldInfo)
                getFieldForDiscrMethod.Invoke(null, new object[] { s2.DiscriminatorValue });
            Assert.NotNull(fieldForDiscr1, "fieldForDiscr1");
            Assert.NotNull(fieldForDiscr2, "fieldForDiscr2");
            Assert.AreEqual(((TypeCodeImpl)s1.ElementType).GetClsForTypeCode(),
                                   fieldForDiscr1.FieldType, "fieldForDiscr1 Type");
            Assert.AreEqual(
                                   ((TypeCodeImpl)s2.ElementType).GetClsForTypeCode(),
                                   fieldForDiscr2.FieldType, "fieldForDiscr2 Type");
            PropertyInfo discrProperty = res.GetProperty(UnionGenerationHelper.DISCR_PROPERTY_NAME,
                                                         BindingFlags.Public | BindingFlags.Instance);
            Assert.NotNull(discrProperty, "discr property");
            Assert.AreEqual(discrTC.GetClsForTypeCode(),
                                   discrProperty.PropertyType, "discr property type");
            Assert.IsTrue(res.IsSerializable, "Serializable");
        }
        public void TestGenerateSpecialNameRepId()
        {
            string name = "TestBoxedGenForTypeCodeType3";
            string typeName = "Ch.Elca.Iiop.Tests." + name;
            string repId = "IDL:Ch/Elca/Iiop/Tests/Special_TestBoxedGenForTypeCodeType3:1.0";
            LongTC boxedTC = new LongTC();
            ValueBoxTC vt = new ValueBoxTC(repId,
                                           name,
                                           boxedTC);

            Type res = m_gen.CreateOrGetType(typeName, vt);
            Assert.NotNull(res);
            Assert.AreEqual(typeName, res.FullName, "type name");
            Assert.AreEqual(repId, Repository.GetRepositoryID(res), "rep id");
        }
Exemplo n.º 6
0
 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");
 }
Exemplo n.º 7
0
 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);
     }
 }