public bool PosTest2()
    {
        bool retVal = true;

        const string c_TEST_ID   = "P002";
        string       c_TEST_DESC = "PosTest2: Verify set accessor of property RuntimeCompatibilityAttribute.WrapNonExceptionThrows";
        string       errorDesc;

        bool expectedValue, actualValue;

        expectedValue = (TestLibrary.Generator.GetInt32(-55) & 1) == 0;
        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
        try
        {
            RuntimeCompatibilityAttribute runtimeCompaibilityAtt = new RuntimeCompatibilityAttribute();
            runtimeCompaibilityAtt.WrapNonExceptionThrows = expectedValue;
            actualValue = runtimeCompaibilityAtt.WrapNonExceptionThrows;
            if (actualValue != expectedValue)
            {
                errorDesc = "The value of property RuntimeCompatibilityAttribute.WrapNonExceptionThrows " +
                            "is not the value " + expectedValue + " as expected, actually(" + actualValue +
                            ")";
                TestLibrary.TestFramework.LogError("003" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpected exception: " + e;
            TestLibrary.TestFramework.LogError("004" + " TestId-" + c_TEST_ID, errorDesc);
            retVal = false;
        }

        return(retVal);
    }
예제 #2
0
    public bool PosTest1()
    {
        bool retVal = true;

        const string c_TEST_ID   = "P001";
        string       c_TEST_DESC = "PosTest1: initialize an instance of type RuntimeCompatibilityAttribute via default constructor";
        string       errorDesc;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
        try
        {
            RuntimeCompatibilityAttribute runtimeCompaibilityAtt = new RuntimeCompatibilityAttribute();
            if (null == runtimeCompaibilityAtt)
            {
                errorDesc = "Failed to initialize an instance of type RuntimeCompatibilityAttribute via default constructor.";
                TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpected exception: " + e;
            TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, errorDesc);
            retVal = false;
        }

        return(retVal);
    }
    public bool PosTest1()
    {
        bool retVal = true;

        const string c_TEST_ID = "P001";
        string c_TEST_DESC = "PosTest1: initialize an instance of type RuntimeCompatibilityAttribute via default constructor";
        string errorDesc;

        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
        try
        {
            RuntimeCompatibilityAttribute runtimeCompaibilityAtt = new RuntimeCompatibilityAttribute();
            if (null == runtimeCompaibilityAtt)
            {
                errorDesc = "Failed to initialize an instance of type RuntimeCompatibilityAttribute via default constructor.";
                TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpected exception: " + e;
            TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, errorDesc);
            retVal = false;
        }

        return retVal;
    }
    public bool PosTest1()
    {
        bool retVal = true;

        const string c_TEST_ID = "P001";
        string c_TEST_DESC = "PosTest1: Verify get accessor of property RuntimeCompatibilityAttribute.WrapNonExceptionThrows";
        string errorDesc;

        bool expectedValue, actualValue;
        expectedValue = false;
        TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
        try
        {
            RuntimeCompatibilityAttribute runtimeCompaibilityAtt = new RuntimeCompatibilityAttribute();
            actualValue = runtimeCompaibilityAtt.WrapNonExceptionThrows;
            if (actualValue != expectedValue)
            {
                errorDesc = "The value of property RuntimeCompatibilityAttribute.WrapNonExceptionThrows " +
                            "is not the value " + expectedValue + " as expected, actually(" + actualValue +
                            ")";
                TestLibrary.TestFramework.LogError("001" + " TestId-" + c_TEST_ID, errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpected exception: " + e;
            TestLibrary.TestFramework.LogError("002" + " TestId-" + c_TEST_ID, errorDesc);
            retVal = false;
        }

        return retVal;
    }
예제 #5
0
        public static void RuntimeCompatibilityAttributeTests()
        {
            var attr = new RuntimeCompatibilityAttribute();

            Assert.False(attr.WrapNonExceptionThrows);
            attr.WrapNonExceptionThrows = true;
            Assert.True(attr.WrapNonExceptionThrows);
        }
예제 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello,NET 4.0");

            RuntimeCompatibilityAttribute attr = new RuntimeCompatibilityAttribute();
            FileStream      fileStream         = new FileStream("f:\\temp.dat", FileMode.Create);
            BinaryFormatter b = new BinaryFormatter();

            b.Serialize(fileStream, attr);

            string s         = attr.ToString();
            string classname = "ActorInfo";
            string tx        = string.Format("static StringItem s_{0}-{0}Methods[]={{", classname);

            Console.WriteLine(tx);
            Type type = typeof(Program);

            if (type.Name == "Program")
            {
                // Name=>
            }
            Console.WriteLine("Type Name:" + type.Name);
            Console.WriteLine("Type Name:" + type.FullName);

            Type t = Type.GetType("HelloWorld.Program");

            Program p = (Program)Activator.CreateInstance(t);

            p.test();

            MethodInfo   method = t.GetMethod("test");
            BindingFlags flag   = BindingFlags.Public | BindingFlags.Instance;

            object[] parameters  = new object[] { };
            object   returnValue = method.Invoke(p, parameters);

            MonthDay e1 = MonthDay.Monday;

            Console.WriteLine("e:" + e1.ToString());

            Object   o  = Enum.Parse(typeof(MonthDay), "Monday");
            MonthDay o1 = (MonthDay)o;

            Console.WriteLine("MonthDay:" + o1);
        }
예제 #7
0
    static int Main()
    {
        object [] attrs = typeof(X).Assembly.GetCustomAttributes(true);

        foreach (object o in attrs)
        {
            if (o is RuntimeCompatibilityAttribute)
            {
                RuntimeCompatibilityAttribute a = (RuntimeCompatibilityAttribute)o;

                if (a.WrapNonExceptionThrows)
                {
                    return(0);
                }
            }
        }

        // failed, did not find the attribute
        return(1);
    }
 public CodeAttributeDeclaration Convert(RuntimeCompatibilityAttribute attribute)
 {
     return(new CodeAttributeDeclaration(new CodeTypeReference(attribute.GetType())));
 }