当前位置: 首页>>代码示例>>C#>>正文


C# Logger.assure方法代码示例

本文整理汇总了C#中Logger.assure方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.assure方法的具体用法?C# Logger.assure怎么用?C# Logger.assure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Logger的用法示例。


在下文中一共展示了Logger.assure方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: testS1

    public void testS1(Logger l) {
        l.Function = "testS1";
        object obj = new Object();
        ucss.uno.RuntimeException excRuntime =
            new ucss.uno.RuntimeException("RuntimeException", obj);
        ucss.uno.Exception excException =
            new ucss.uno.Exception("Exception", obj);
        ucss.lang.IllegalAccessException excIllegalAccess =
            new ucss.lang.IllegalAccessException("IllegalAccessException", obj);
        ucss.uno.DeploymentException excDeployment =
            new ucss.uno.DeploymentException("DeploymentException", obj);
        ucss.lang.InvalidListenerException excInvalidListener =
            new ucss.lang.InvalidListenerException("ListenerException", obj);
        
        /* create1 does not specify exceptions. Therefore RuntimeExceptions
           fly through and other exceptions cause a DeploymentException.
        */            
        try {
            S1.create1(new Context(Context.test_kind.TEST_EXCEPTION, excRuntime));
        } catch (ucss.uno.RuntimeException e) {
            l.assure(e.Message == excRuntime.Message
                     && e.Context == obj);
        } catch (System.Exception) {
            l.assure(false);
        }

        Context c = new Context(Context.test_kind.TEST_EXCEPTION, excException); 
        try {
            S1.create1(c);
        } catch (ucss.uno.DeploymentException e) {
            //The message of the original exception should be contained
            // in the Deploymentexception
            l.assure(e.Message.IndexOf(excException.Message) != -1 && e.Context == c);
        } catch (System.Exception) {
            l.assure(false);
        }

        /* create2 specifies many exceptions, including RuntimeException and Exception.
           Because Exception is specified all exceptions are allowed, hence all thrown
           exceptions fly through.
         */
        try {
            S1.create2(new Context(Context.test_kind.TEST_EXCEPTION, excRuntime));
        } catch (ucss.uno.RuntimeException e) {
            l.assure(e.Message == excRuntime.Message
                     && e.Context == obj);
        } catch (System.Exception) {
            l.assure(false);
        }

        try {
            S1.create2(new Context(Context.test_kind.TEST_EXCEPTION, excIllegalAccess));
        } catch (ucss.lang.IllegalAccessException e) {
            l.assure(e.Message == excIllegalAccess.Message
                     && e.Context == obj);
        } catch (System.Exception) {
            l.assure(false);
        }

        try {
            S1.create2(new Context(Context.test_kind.TEST_EXCEPTION, excException));
        } catch (ucss.uno.Exception e) {
            l.assure(e.Message == excException.Message
                     && e.Context == obj);
        } catch (System.Exception) {
            l.assure(false);
        }

        /* create3 specifies exceptions but no com.sun.star.uno.Exception. RuntimeException
           and derived fly through. Other specified exceptions are rethrown and all other
           exceptions cause a DeploymentException.
        */
        try {
            S1.create3(new Context(Context.test_kind.TEST_EXCEPTION, excDeployment),
                       new Any[]{});
        } catch (ucss.uno.DeploymentException e) {
            l.assure(e.Message == excDeployment.Message
                     && e.Context == obj);
        } catch (System.Exception) {
            l.assure(false);
        }

        try {
            S1.create3(new Context(Context.test_kind.TEST_EXCEPTION, excIllegalAccess),
                       new Any[0]);
        } catch (ucss.lang.IllegalAccessException e) {
            l.assure(e.Message == excIllegalAccess.Message
                     && e.Context == obj);
        } catch (System.Exception) {
            l.assure(false);
        }

        c = new Context(Context.test_kind.TEST_EXCEPTION, excInvalidListener);
        try {
            S1.create3(c, new Any[0]);
        } catch (ucss.uno.DeploymentException e) {
            l.assure(e.Message.IndexOf(excInvalidListener.Message) != -1
                     && e.Context == c);
        } catch (System.Exception) {
            l.assure(false);
//.........这里部分代码省略.........
开发者ID:sdmckenzie,项目名称:core,代码行数:101,代码来源:climaker.cs

示例2: testEmptyStruct2

 public void testEmptyStruct2(Logger l) {
     l.Function = "testEmptyStruct2";
     Struct2 s = new Struct2();
     l.assure(s.p1 == false);
     l.assure(s.p2 == 0);
     l.assure(s.p3 == 0);
     l.assure(s.p4 == 0);
     l.assure(s.p5 == 0);
     l.assure(s.p6 == 0);
     l.assure(s.p7 == 0L);
     l.assure(s.p8 == 0L);
     l.assure(s.p9 == 0.0f);
     l.assure(s.p10 == 0.0);
     l.assure(s.p11 == '\u0000');
     l.assure(s.p12.Equals(""));
     l.assure(s.p13.Equals(typeof(void)));
     l.assure(s.p14.Equals(Any.VOID));
     l.assure(s.p15 == Enum2.VALUE0);
     l.assure(s.p16.member1 == 0);
     l.assure(s.p17 == null);
     l.assure(s.p18 == null);
     l.assure(s.t1 == false);
     l.assure(s.t2 == 0);
     l.assure(s.t3 == 0);
     l.assure(s.t4 == 0);
     l.assure(s.t5 == 0);
     l.assure(s.t6 == 0);
     l.assure(s.t7 == 0L);
     l.assure(s.t8 == 0L);
     l.assure(s.t9 == 0.0f);
     l.assure(s.t10 == 0.0);
     l.assure(s.t11 == '\u0000');
     l.assure(s.t12.Equals(""));
     l.assure(s.t13.Equals(typeof(void)));
     l.assure(s.t14.Equals(Any.VOID));
     l.assure(s.t15 == Enum2.VALUE0);
     l.assure(s.t16.member1 == 0);
     l.assure(s.t17 == null);
     l.assure(s.t18 == null);
     l.assure(s.a1.Length == 0);
     l.assure(s.a2.Length == 0);
     l.assure(s.a3.Length == 0);
     l.assure(s.a4.Length == 0);
     l.assure(s.a5.Length == 0);
     l.assure(s.a6.Length == 0);
     l.assure(s.a7.Length == 0);
     l.assure(s.a8.Length == 0);
     l.assure(s.a9.Length == 0);
     l.assure(s.a10.Length == 0);
     l.assure(s.a11.Length == 0);
     l.assure(s.a12.Length == 0);
     l.assure(s.a13.Length == 0);
     l.assure(s.a14.Length == 0);
     l.assure(s.a15.Length == 0);
     l.assure(s.a16.Length == 0);
     l.assure(s.a17.Length == 0);
     l.assure(s.a18.Length == 0);
     l.assure(s.aa1.Length == 0);
     l.assure(s.aa2.Length == 0);
     l.assure(s.aa3.Length == 0);
     l.assure(s.aa4.Length == 0);
     l.assure(s.aa5.Length == 0);
     l.assure(s.aa6.Length == 0);
     l.assure(s.aa7.Length == 0);
     l.assure(s.aa8.Length == 0);
     l.assure(s.aa9.Length == 0);
     l.assure(s.aa10.Length == 0);
     l.assure(s.aa11.Length == 0);
     l.assure(s.aa12.Length == 0);
     l.assure(s.aa13.Length == 0);
     l.assure(s.aa14.Length == 0);
     l.assure(s.aa15.Length == 0);
     l.assure(s.aa16.Length == 0);
     l.assure(s.aa17.Length == 0);
     l.assure(s.aa18.Length == 0);
     l.assure(s.at1.Length == 0);
     l.assure(s.at2.Length == 0);
     l.assure(s.at3.Length == 0);
     l.assure(s.at4.Length == 0);
     l.assure(s.at5.Length == 0);
     l.assure(s.at6.Length == 0);
     l.assure(s.at7.Length == 0);
     l.assure(s.at8.Length == 0);
     l.assure(s.at9.Length == 0);
     l.assure(s.at10.Length == 0);
     l.assure(s.at11.Length == 0);
     l.assure(s.at12.Length == 0);
     l.assure(s.at13.Length == 0);
     l.assure(s.at14.Length == 0);
     l.assure(s.at15.Length == 0);
     l.assure(s.at16.Length == 0);
     l.assure(s.at17.Length == 0);
     l.assure(s.at18.Length == 0);
 }
开发者ID:sdmckenzie,项目名称:core,代码行数:94,代码来源:climaker.cs

示例3: testFullStruct2

 public void testFullStruct2(Logger l) {
     //TODO:
     Struct2 s = new Struct2(
         true, (byte) 1, (short) 2, (ushort) 3, 4, 5, 6L, 7L, 0.8f, 0.9d, 'A',
         "BCD", typeof(ulong), new Any(22), Enum2.VALUE4,
         new Struct1(1), null, null, false, (byte) 0, (short) 0, (ushort) 0,
         0, 0, 0L, 0L, 0.0f, 0.0, '\u0000', "", typeof(void), Any.VOID,
         Enum2.VALUE0, new Struct1(), null, null,
         new bool[] { false, true }, new byte[] { (byte) 1, (byte) 2 },
         new short[0], new ushort[0], new int[0], new uint[0],
         new long[0], new ulong[0], new float[0], new double[0], new char[0],
         new String[0], new Type[0], new Any[0], new Enum2[0],
         new Struct1[] { new Struct1(1), new Struct1(2) }, new Object[0],
         new ucss.uno.XNamingService[0], new bool[0][], new byte[0][],
         new short[0][], new ushort[0][], new int[0][], new uint[0][],
         new long[0][], new ulong[0][], new float[0][], new double[0][],
         new char[0][], new String[0][], new Type[0][], new Any[0][],
         new Enum2[0][], new Struct1[0][], new Object[0][],
         new ucss.uno.XNamingService[0][], new bool[0][], new byte[0][],
         new short[0][], new ushort[0][], new int[0][], new uint[0][],
         new long[0][], new ulong[0][], new float[0][], new double[0][],
         new char[0][], new String[0][], new Type[0][], new Any[0][],
         new Enum2[0][], new Struct1[0][], new Object[0][],
         new ucss.uno.XNamingService[0][]);
     l.assure(s.p1 == true);
     l.assure(s.p2 == 1);
     l.assure(s.p3 == 2);
     l.assure(s.p4 == 3);
     l.assure(s.p5 == 4);
     l.assure(s.p6 == 5);
     l.assure(s.p7 == 6L);
     l.assure(s.p8 == 7L);
     l.assure(s.p9 == 0.8f);
     l.assure(s.p10 == 0.9);
     l.assure(s.p11 == 'A');
     l.assure(s.p12.Equals("BCD"));
     l.assure(s.p13.Equals(typeof(ulong)));
     l.assure(s.p14.Equals(new Any(22)));
     l.assure(s.p15 == Enum2.VALUE4);
     l.assure(s.p16.member1 == 1);
     l.assure(s.p17 == null);
     l.assure(s.p18 == null);
     l.assure(s.t1 == false);
     l.assure(s.t2 == 0);
     l.assure(s.t3 == 0);
     l.assure(s.t4 == 0);
     l.assure(s.t5 == 0);
     l.assure(s.t6 == 0);
     l.assure(s.t7 == 0L);
     l.assure(s.t8 == 0L);
     l.assure(s.t9 == 0.0f);
     l.assure(s.t10 == 0.0);
     l.assure(s.t11 == '\u0000');
     l.assure(s.t12.Equals(""));
     l.assure(s.t13.Equals(typeof(void)));
     l.assure(s.t14.Equals(Any.VOID));
     l.assure(s.t15 == Enum2.VALUE0);
     l.assure(s.t16.member1 == 0);
     l.assure(s.t17 == null);
     l.assure(s.t18 == null);
     l.assure(s.a1.Length == 2);
     l.assure(s.a1[0] == false);
     l.assure(s.a1[1] == true);
     l.assure(s.a2.Length == 2);
     l.assure(s.a2[0] == 1);
     l.assure(s.a2[1] == 2);
     l.assure(s.a3.Length == 0);
     l.assure(s.a4.Length == 0);
     l.assure(s.a5.Length == 0);
     l.assure(s.a6.Length == 0);
     l.assure(s.a7.Length == 0);
     l.assure(s.a8.Length == 0);
     l.assure(s.a9.Length == 0);
     l.assure(s.a10.Length == 0);
     l.assure(s.a11.Length == 0);
     l.assure(s.a12.Length == 0);
     l.assure(s.a13.Length == 0);
     l.assure(s.a14.Length == 0);
     l.assure(s.a15.Length == 0);
     l.assure(s.a16.Length == 2);
     l.assure(s.a16[0].member1 == 1);
     l.assure(s.a16[1].member1 == 2);
     l.assure(s.a17.Length == 0);
     l.assure(s.a18.Length == 0);
     l.assure(s.aa1.Length == 0);
     l.assure(s.aa2.Length == 0);
     l.assure(s.aa3.Length == 0);
     l.assure(s.aa4.Length == 0);
     l.assure(s.aa5.Length == 0);
     l.assure(s.aa6.Length == 0);
     l.assure(s.aa7.Length == 0);
     l.assure(s.aa8.Length == 0);
     l.assure(s.aa9.Length == 0);
     l.assure(s.aa10.Length == 0);
     l.assure(s.aa11.Length == 0);
     l.assure(s.aa12.Length == 0);
     l.assure(s.aa13.Length == 0);
     l.assure(s.aa14.Length == 0);
     l.assure(s.aa15.Length == 0);
     l.assure(s.aa16.Length == 0);
//.........这里部分代码省略.........
开发者ID:sdmckenzie,项目名称:core,代码行数:101,代码来源:climaker.cs

示例4: testEnum2

 public void testEnum2(Logger l) {
     l.Function = "testEnum2";
     l.assure( ((int) Enum2.VALUE0) == 0);
     l.assure( ((int) Enum2.VALUE1) == 1);
     l.assure( ((int) Enum2.VALUE2) == 2);
     l.assure( ((int) Enum2.VALUE4) == 4);
 }
开发者ID:sdmckenzie,项目名称:core,代码行数:7,代码来源:climaker.cs

示例5: testPolyStruct

 public void testPolyStruct(Logger l) {
     l.Function = "testPolyStruct";
     PolyStruct s = new PolyStruct();
     l.assure(s.member1 == null);
     l.assure(s.member2 == 0);
     s = new PolyStruct("ABC", 5);
     l.assure(s.member1.Equals("ABC"));
     l.assure(s.member2 == 5);
 }
开发者ID:sdmckenzie,项目名称:core,代码行数:9,代码来源:climaker.cs

示例6: testAny

    public void testAny(Logger l)
    {
        l.Function = "testAny";
        //create any with valid and invalid arguments
        try
        {
            Any a = new Any(null, null);
            l.assure(false);
        }
        catch(System.Exception e)
        {
            l.assure(e.Message.IndexOf("Any") != -1);
        }
        try
        {
            Any a = new Any(typeof(int), null);
            l.assure(false);
        }
        catch(System.Exception e)
        {
            l.assure(e.Message.IndexOf("Any") != -1);
        }
        

        try
        {
            Any a = new Any(typeof(unoidl.com.sun.star.uno.XComponentContext), null);
            a = new Any('a');
            a = new Any((sbyte)1);
        }
        catch (System.Exception)
        {
            l.assure(false);
        }

        //test polymorphic struct
        try
        {
            Any a = new Any(typeof(unoidl.test.cliure.climaker.PolyStruct),
                            new PolyStruct());
            l.assure(false);
        }
        catch (System.Exception e)
        {
            l.assure(e.Message.IndexOf("Any") != -1);
        }
        try
        {
            Any a = new Any(uno.PolymorphicType.GetType(
                                typeof(unoidl.test.cliure.climaker.PolyStruct),
                                "unoidl.test.cliure.climaker.PolyStruct<System.Char>"),
                            new PolyStruct('A', 10));
        }
        catch (System.Exception )
        {
            l.assure(false);
        }

        //test Any.Equals

        Any aVoid = Any.VOID;
        l.assure(aVoid.Equals((object) Any.VOID));
        l.assure(aVoid.Equals(Any.VOID));

        l.assure(aVoid.Equals(new Any("")) == false);

        Any a1 = new Any(10);
        Any a2 = a1;
        l.assure(a1.Equals(a2));

        a1 = new Any(typeof(unoidl.com.sun.star.uno.XComponentContext), null);
        l.assure(a1.Equals(a2) == false);
        a2 = a1;
        l.assure(a1.Equals(a2));
        l.assure(a1.Equals(null) == false);
        l.assure(a1.Equals(new object()) == false);
    }
开发者ID:sdmckenzie,项目名称:core,代码行数:77,代码来源:climaker.cs

示例7: testEnum1

 public void testEnum1(Logger l) {
     l.Function = "testEnum1";
     l.assure(((int)Enum1.VALUE1) == -100);
     l.assure(((int)Enum1.VALUE2) == 100);
 }
开发者ID:sdmckenzie,项目名称:core,代码行数:5,代码来源:climaker.cs

示例8: testInterface

    void testInterface(Logger l)
    {
        l.Function = "testInterface";
        try {
            Context c = new Context(Context.test_kind.NORMAL);
            XTest obj = S1.create1(c);
            bool aBool = true;
            byte aByte = 0xff;
            short aShort =   0x7fff;
            ushort aUShort =   0xffff;
            int aInt  = 0x7fffffff;
            uint aUInt = 0xffffffff;
            long aLong = 0x7fffffffffffffff;
            ulong aULong = 0xffffffffffffffff;
            float aFloat = 0.314f;
            double aDouble = 0.314d;
            char aChar  = 'A';
            string aString = "Hello World";
            Type aType = typeof(XTest);
            Any aAny = new Any(typeof(XTest), obj);
            Enum2 aEnum2 = Enum2.VALUE2;
            Struct1 aStruct1 = new Struct1();
            object aXInterface = new object();
            ucss.lang.XComponent aXComponent = (ucss.lang.XComponent) obj;
            bool[] aSeqBool = {true, false, true};
            
            obj.inParameters(aBool, aByte, aShort, aUShort,
                             aInt, aUInt, aLong, aULong,
                             aFloat, aDouble, aChar, aString,
                             aType, aAny,aEnum2, aStruct1,
                             aXInterface, aXComponent, aSeqBool);

            bool outBool;
            byte outByte;
            short outShort;
            ushort outUShort;
            int outInt;
            uint outUInt;
            long outLong;
            ulong outULong;
            float outFloat;
            double outDouble;
            char outChar;
            string outString;
            Type outType;
            Any outAny;
            Enum2 outEnum2;
            Struct1 outStruct1;
            object outXInterface;
            ucss.lang.XComponent outXComponent;
            bool[] outSeqBool;

            obj.outParameters(out outBool, out outByte, out  outShort, out outUShort,
                              out outInt, out outUInt, out outLong, out outULong,
                              out outFloat, out outDouble, out outChar, out outString,
                              out outType, out outAny, out outEnum2, out outStruct1,
                              out outXInterface, out outXComponent, out outSeqBool);

            l.assure(aBool == outBool);
            l.assure(aByte == outByte);
            l.assure(aShort == outShort);
            l.assure(aUShort == outUShort);
            l.assure(aInt == outInt);
            l.assure(aUInt == outUInt);
            l.assure(aLong == outLong);
            l.assure(aULong == outULong);
            l.assure(aFloat == outFloat);
            l.assure(aDouble == outDouble);
            l.assure(aChar == outChar);
            l.assure(aString == outString);
            l.assure(aType == outType);
            l.assure(aAny.Equals(outAny));
            l.assure(aEnum2 == outEnum2);
            l.assure(aStruct1 == outStruct1);
            l.assure(aXInterface == outXInterface);
            l.assure(aXComponent == outXComponent);
            l.assure(aSeqBool == outSeqBool);

            bool inoutBool = false;
            byte inoutByte = 10;
            short inoutShort = 11;
            ushort inoutUShort = 12;
            int inoutInt = 13;
            uint inoutUInt = 14;
            long inoutLong = 15;
            ulong inoutULong = 16;
            float inoutFloat = 4.134f;
            double inoutDouble = 5.135;
            char inoutChar = 'B';
            string inoutString =  "Hello Hamburg";
            Type inoutType = typeof(int);
            Any inoutAny = new Any(inoutInt);
            Enum2 inoutEnum2 = Enum2.VALUE4;
            Struct1 inoutStruct1 = new Struct1();
            object inoutXInterface = new object();
            ucss.lang.XComponent inoutXComponent = (ucss.lang.XComponent) S1.create1(c);
            bool[] inoutSeqBool = {false, true, false};


            obj.inoutParameters(ref inoutBool, ref inoutByte, ref inoutShort, ref inoutUShort,
//.........这里部分代码省略.........
开发者ID:sdmckenzie,项目名称:core,代码行数:101,代码来源:climaker.cs

示例9: testPolymorphicType

//     private XComponentContext context;

        void testPolymorphicType(Logger l)
        {
            l.Function = "testPolymorphicType";
            string name = "unoidl.test.cliure.climaker.PolyStruct<System.Int32,System.Int32>";

            uno.PolymorphicType t1 = PolymorphicType.GetType(
                typeof(unoidl.test.cliure.climaker.PolyStruct), name);

            uno.PolymorphicType t2 = PolymorphicType.GetType(
                typeof(unoidl.test.cliure.climaker.PolyStruct ), name);

            l.assure(t1 == t2);
            l.assure(t1.PolymorphicName == name);
            l.assure(t1.OriginalType == typeof(unoidl.test.cliure.climaker.PolyStruct));
            
        }
开发者ID:sdmckenzie,项目名称:core,代码行数:18,代码来源:climaker.cs

示例10: testPolyStructAttributes

    void testPolyStructAttributes(Logger l)
    {
        l.Function = "testPolyStructAttributes";
        //Test polymorphic struct
        Type typeStruct = typeof(unoidl.test.cliure.climaker.PolyStruct);
        object[] arAttr = typeStruct.GetCustomAttributes(false);
        if (arAttr.Length == 1)
        {
            try {
            uno.TypeParametersAttribute attr = (uno.TypeParametersAttribute) arAttr[0];
            string[] arNames = new string[]{"if", "else"};
            l.assure(attr != null && attr.Parameters.ToString().Equals(arNames.ToString()));
            }catch(Exception ) {
                l.assure(false);
            }
        }
        else
            l.assure(false);
        l.assure(typeof(unoidl.test.cliure.climaker.Struct1).GetCustomAttributes(false).Length == 0);
        //member of a polymorphic struct with a parameterized type have also an attribute
        arAttr = typeStruct.GetField("member1").GetCustomAttributes(false);
        if (arAttr.Length == 1)
        {
            uno.ParameterizedTypeAttribute attr = arAttr[0] as uno.ParameterizedTypeAttribute;
            l.assure(attr != null && attr.Type == "if");
        }
        else
            l.assure(false);

        
        //test instantiated polymorphic struct: return value        
//         Type typeXTest = typeof(XTest);
//         arAttr = typeXTest.GetMethod("testPolyStruct").ReturnTypeCustomAttributes.GetCustomAttributes(false);
//         if (arAttr.Length == 1)
//         {
//             uno.TypeArgumentsAttribute attr = arAttr[0] as uno.TypeArgumentsAttribute;
//             l.assure(attr != null && attr.Arguments.Length == 2
//                      &&attr.Arguments[0] == typeof(char)
//                      && attr.Arguments[1] == typeof(int));
//         }
//         else
//             l.assure(false);
//         arAttr = typeXTest.GetMethod("testPolyStruct").GetCustomAttributes(false);
    }
开发者ID:sdmckenzie,项目名称:core,代码行数:44,代码来源:climaker.cs

示例11: testAttributes

    void testAttributes(Logger l)
    {
        l.Function = "testAttributes";
        //oneway attribute
        Type typeXTest = typeof(unoidl.test.cliure.climaker.XTest);
        object[] arAttr = typeXTest.GetMethod("testOneway").GetCustomAttributes(false);
        if (arAttr.Length == 1)
            l.assure(typeof(uno.OnewayAttribute).Equals(arAttr[0].GetType()));
        else
            l.assure(false);

        //test exceptions
        arAttr = typeXTest.GetMethod("testExceptions").GetCustomAttributes(false);
        if (arAttr.Length == 1 && arAttr[0].GetType() == typeof(uno.ExceptionAttribute))
        {
            uno.ExceptionAttribute attr = arAttr[0] as uno.ExceptionAttribute;
            if (attr != null && attr.Raises.Length == 2)
            {
                l.assure(attr.Raises[0] == typeof(unoidl.com.sun.star.uno.Exception));
                l.assure(attr.Raises[1] == typeof(unoidl.com.sun.star.lang.ClassNotFoundException));
            }
            else
                l.assure(false);
        }
        else
            l.assure(false);
        
        //function test must not have the oneway attribute and Exception attribute
        arAttr = typeXTest.GetMethod("test").GetCustomAttributes(false);
        l.assure(arAttr.Length == 0);

        //test exceptions on service constructor methods
        Type typeS1 = typeof(unoidl.test.cliure.climaker.S1);
        arAttr = typeS1.GetMethod("create3").GetCustomAttributes(false);
        if (arAttr.Length == 1 && arAttr[0].GetType() == typeof(uno.ExceptionAttribute))
        {
            uno.ExceptionAttribute attr = arAttr[0] as uno.ExceptionAttribute;
            if (attr != null && attr.Raises.Length == 4)
            {
                l.assure(attr.Raises[0] == typeof(unoidl.com.sun.star.uno.RuntimeException));
                l.assure(attr.Raises[1] == typeof(unoidl.com.sun.star.lang.ClassNotFoundException));
                l.assure(attr.Raises[2] == typeof(unoidl.com.sun.star.lang.IllegalAccessException));
                l.assure(attr.Raises[3] == typeof(unoidl.com.sun.star.uno.DeploymentException));
            }
            else
                l.assure(false);
        }
        else
            l.assure(false);

        //create1 does not have exceptions
        arAttr = typeS1.GetMethod("create1").GetCustomAttributes(false);
        l.assure(arAttr.Length == 0);

        //test exceptions of UNO interface attributes
        arAttr = typeXTest.GetProperty("A3").GetGetMethod().GetCustomAttributes(false);
        if (arAttr.Length == 1)
        {
            uno.ExceptionAttribute attr = arAttr[0] as uno.ExceptionAttribute;
            if (attr != null && attr.Raises.Length == 2)
            {
                l.assure(attr.Raises[0] == typeof(unoidl.com.sun.star.uno.Exception));
                l.assure(attr.Raises[1] == typeof(unoidl.com.sun.star.lang.ClassNotFoundException));
            }
            else
                l.assure(false);
        }
        else
            l.assure(false);

        arAttr = typeXTest.GetProperty("A3").GetSetMethod().GetCustomAttributes(false);
        if (arAttr.Length == 1)
        {
            uno.ExceptionAttribute attr = arAttr[0] as uno.ExceptionAttribute;
            if (attr != null && attr.Raises.Length == 1)
                l.assure(attr.Raises[0] == typeof(unoidl.com.sun.star.uno.RuntimeException));
            else
                l.assure(false);
        }
        else
            l.assure(false);

        //attribute A1 must have the ExceptionAttribute
        l.assure(typeXTest.GetProperty("A1").GetGetMethod().GetCustomAttributes(false).Length == 0);
        l.assure(typeXTest.GetProperty("A1").GetSetMethod().GetCustomAttributes(false).Length == 0);

        //Test BoundAttribute
        BoundAttribute bound = (BoundAttribute) Attribute.GetCustomAttribute(
            typeXTest.GetProperty("A1"), typeof(BoundAttribute));
        l.assure(bound != null);

        bound = (BoundAttribute) Attribute.GetCustomAttribute(
            typeXTest.GetProperty("A3"), typeof(BoundAttribute));
        l.assure(bound == null);
    }
开发者ID:sdmckenzie,项目名称:core,代码行数:95,代码来源:climaker.cs

示例12: testSingletons

    void testSingletons(Logger l)
    {
        l.Function = "testSingletons";
        Context c = new Context(Context.test_kind.NORMAL);
        try {
			XTest obj = S4.get(c);
			l.assure(obj != null);
        } catch (Exception) {
            l.assure(false);
        }

        /** Case context fails to provide sigleton, a DeploymentException should be thrown.
         */
        c = new Context(Context.test_kind.CREATION_FAILED);
        try {
			XTest obj = S4.get(c);
			l.assure(obj != null);
        } catch (ucss.uno.DeploymentException e) {
            Type t = typeof(unoidl.test.cliure.climaker.S4);
            l.assure( e.Message.IndexOf(t.FullName) != -1);
        } catch (System.Exception) {
            l.assure(false);
        }
    }
开发者ID:sdmckenzie,项目名称:core,代码行数:24,代码来源:climaker.cs


注:本文中的Logger.assure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。