コード例 #1
0
        public void test_excps_export()
        {
            Object[] boolObject   = new Object[] { ConstsTest1.BOOL1, ConstsTest1.BOOL2 };
            Object[] byteObject   = new Object[] { ConstsTest1.BYTE1, ConstsTest1.BYTE2, ConstsTest1.BYTE3, ConstsTest1.BYTE4, ConstsTest1.BYTE5 };
            Object[] shortObject  = new Object[] { ConstsTest1.SHORT1, ConstsTest1.SHORT2, ConstsTest1.SHORT3, ConstsTest1.SHORT4, ConstsTest1.SHORT5 };
            Object[] intObject    = new Object[] { ConstsTest1.INT1, ConstsTest1.INT2, ConstsTest1.INT3, ConstsTest1.INT4, ConstsTest1.INT5 };
            Object[] longObject   = new Object[] { ConstsTest1.LONG1, ConstsTest1.LONG2, ConstsTest1.LONG3, ConstsTest1.LONG4, ConstsTest1.LONG5 };
            Object[] floatObject  = new Object[] { ConstsTest1.FLOAT1, ConstsTest1.FLOAT2, ConstsTest1.FLOAT3, ConstsTest1.FLOAT4, ConstsTest1.FLOAT5 };
            Object[] doubleObject = new Object[] { ConstsTest1.DOUBLE1, ConstsTest1.DOUBLE2, ConstsTest1.DOUBLE3, ConstsTest1.DOUBLE4, ConstsTest1.DOUBLE5 };
            Object[] stringObject = new Object[] { ConstsTest1.STRING1, ConstsTest1.STRING2, ConstsTest1.STRING3, ConstsTest1.STRING4, ConstsTest1.STRING5 };

            String msg  = "Exception";
            int    code = 500;

            StructValue sv = vf.ExportCustomValue(new Excp1("abc", 23));

            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp1);
            Assert.AreEqual(2, sv.Count);
            Assert.AreEqual("abc", sv.Get(ValueFactoryTest1._mf_msg));
            Assert.AreEqual(23, sv.Get(ValueFactoryTest1._mf_code));

            sv = vf.ExportCustomValue(new Excp2());
            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp2);
            Assert.AreEqual(0, sv.Count);

            sv = vf.ExportCustomValue(new Excp3());
            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp3);
            Assert.AreEqual(0, sv.Count);

            sv = vf.ExportCustomValue(new Excp4());
            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp4);
            Assert.AreEqual(0, sv.Count);

            // Import exception with object as param
            testExcp5Export(msg, code, ConstsTest1.BOOL2);
            testExcp5Export(msg, code, ConstsTest1.BYTE5);
            testExcp5Export(msg, code, ConstsTest1.SHORT5);
            testExcp5Export(msg, code, ConstsTest1.INT5);
            testExcp5Export(msg, code, ConstsTest1.LONG5);
            testExcp5Export(msg, code, ConstsTest1.FLOAT5);
            testExcp5Export(msg, code, ConstsTest1.DOUBLE5);
            testExcp5Export(msg, code, ConstsTest1.STRING3);

            // Import exception with array of object as param
            testExcp6Export(msg, code, boolObject);
            testExcp6Export(msg, code, byteObject);
            testExcp6Export(msg, code, shortObject);
            testExcp6Export(msg, code, intObject);
            testExcp6Export(msg, code, longObject);
            testExcp6Export(msg, code, floatObject);
            testExcp6Export(msg, code, doubleObject);
            testExcp6Export(msg, code, stringObject);
        }
コード例 #2
0
        private void testEnumExport(E1 e, XType t, Field f)
        {
            StructValue sv = vf.ExportCustomValue(e);

            sv.CheckType(t);
            Assert.AreEqual(1, sv.Count);
            Assert.IsTrue((Boolean)sv.Get(f));
        }
コード例 #3
0
        private void testS3Export(String s, Object value)
        {
            StructValue sv = vf.ExportCustomValue(new S3(s, value));

            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_S3);
            Assert.AreEqual(2, sv.Count);
            Assert.AreEqual(s, sv[ValueFactoryTest1._mf_tipe]);
            Assert.AreEqual(value, sv[ValueFactoryTest1._mf_x]);
        }
コード例 #4
0
        public void ExportCustomValue_RuntimeException_msg()
        {
            Exception   value = new NullReferenceException("foo != null");
            StructValue sv    = vf.ExportCustomValue(value);

            sv.CheckType(vf.GetType("_Etch_RuntimeException"));
            Assert.AreEqual(1, sv.Count);
            Assert.AreEqual("System.NullReferenceException: foo != null",
                            sv.Get(DefaultValueFactory._mf_msg));
        }
コード例 #5
0
        public void ExportCustomValue_RuntimeException()
        {
            Exception   value = new NullReferenceException();
            StructValue sv    = vf.ExportCustomValue(value);

            sv.CheckType(vf.GetType("_Etch_RuntimeException"));
            Assert.AreEqual(1, sv.Count);
            Assert.AreEqual("System.NullReferenceException: Object reference not set to an instance of an object.",
                            sv.Get(DefaultValueFactory._mf_msg));
        }
コード例 #6
0
        public void test_S1_export()
        {
            StructValue sv = vf.ExportCustomValue(new S1(19, 23, 29));

            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_S1);
            Assert.AreEqual(3, sv.Count);
            Assert.AreEqual(19, sv.Get(ValueFactoryTest1._mf_x));
            Assert.AreEqual(23, sv.Get(ValueFactoryTest1._mf_y));
            Assert.AreEqual(29, sv.Get(ValueFactoryTest1._mf_z));
        }
コード例 #7
0
        private void testExcp6Export(String msg, int code, Object[] value)
        {
            StructValue sv = vf.ExportCustomValue(new Excp6(msg, code, value));

            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp6);
            Assert.AreEqual(3, sv.Count);
            Assert.AreEqual(msg, sv[ValueFactoryTest1._mf_msg]);
            Assert.AreEqual(code, sv[ValueFactoryTest1._mf_code]);
            Assert.AreEqual(value, sv[ValueFactoryTest1._mf_x]);
        }
コード例 #8
0
        public void test_S2_export()
        {
            S1 a = new S1(21, 22, 23);
            S1 b = new S1(31, 32, 33);
            E1 c = E1.A;

            StructValue sv = vf.ExportCustomValue(new S2(a, b, c));

            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_S2);
            Assert.AreEqual(3, sv.Count);

            Assert.AreEqual(a, sv.Get(ValueFactoryTest1._mf_a));
            Assert.AreEqual(b, sv.Get(ValueFactoryTest1._mf_b));
            Assert.AreEqual(c, sv.Get(ValueFactoryTest1._mf_c));
        }
コード例 #9
0
 public override Object ImportValue(StructValue sv)
 {
     sv.CheckType(type);
     return(new _Etch_RuntimeException((String)sv.Get(field)));
 }