Esempio n. 1
0
    public bool NegTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("NegTest1: Convert an enum of negative value to Uint64");

        try
        {
            e_test       e1 = e_test.itemA;
            IConvertible i1 = e1 as IConvertible;
            UInt64       u1 = i1.ToUInt64(null);
            TestLibrary.TestFramework.LogError("101", "The OverflowException was not thrown as expected");
            retVal = false;
        }
        catch (OverflowException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 2
0
    public bool PosTest4()
    {
        bool retVal = true;


        TestLibrary.TestFramework.BeginScenario("PosTest4: Convert a enum to Int64, the value of which is Int64.minvalue");

        try
        {
            e_test       e4 = e_test.itemB;
            IConvertible i4 = e4 as IConvertible;
            long         l4 = i4.ToInt64(null);
            if (l4 != Int64.MinValue)
            {
                TestLibrary.TestFramework.LogError("007", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 3
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Convert an enum of negative value to single");

        try
        {
            e_test       e1 = e_test.itemA;
            IConvertible i1 = e1 as IConvertible;
            float        s1 = (float)i1.ToType(typeof(float), null);
            if (s1 != -123456789.0f)
            {
                TestLibrary.TestFramework.LogError("005", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
            retVal = false;
        }

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

        TestLibrary.TestFramework.BeginScenario("NegTest2: Convert an enum of the value which is bigger than uint16.maxvalue to Uint16");

        try
        {
            e_test       e1 = e_test.itemB;
            IConvertible i1 = e1 as IConvertible;
            UInt16       u1 = i1.ToUInt16(null);
            TestLibrary.TestFramework.LogError("103", "The OverflowException was not thrown as expected");
            retVal = false;
        }
        catch (OverflowException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("104", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 5
0
    public bool NegTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("NegTest1: Convert an enum of int32 to int16");

        try
        {
            e_test       e1 = e_test.itemB;
            IConvertible i1 = e1 as IConvertible;
            Int16        s1 = (Int16)i1.ToType(typeof(Int16), null);
            TestLibrary.TestFramework.LogError("101", "The OverflowException was not thrown as expected");
            retVal = false;
        }
        catch (OverflowException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 6
0
    public bool PosTest6()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest6:Set the first argument as type of double");

        try
        {
            e_test       e1 = e_test.itemC;
            IConvertible i1 = e1 as IConvertible;
            double       s1 = (double)i1.ToType(typeof(double), null);
            if (s1 != (double)Int64.MaxValue)
            {
                TestLibrary.TestFramework.LogError("011", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("012", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 7
0
    public bool PosTest5()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest5: Convert an enum of int32.MinValue to Int32");

        try
        {
            e_test       e1 = e_test.itemB;
            IConvertible i1 = e1 as IConvertible;
            int          s1 = (int)i1.ToType(typeof(int), null);
            if (s1 != Int32.MinValue)
            {
                TestLibrary.TestFramework.LogError("009", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 8
0
    public bool PosTest4()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest4: Convert an enum of int64.MaxValue to Int64 ");

        try
        {
            e_test       e1 = e_test.itemC;
            IConvertible i1 = e1 as IConvertible;
            long         s1 = (long)i1.ToType(typeof(long), null);
            if (s1 != Int64.MaxValue)
            {
                TestLibrary.TestFramework.LogError("007", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("008", "Unexpected exception: " + e);
            retVal = false;
        }

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

        TestLibrary.TestFramework.BeginScenario("PosTest3: Convert an int32 to single");

        try
        {
            e_test       c2 = e_test.itemB;
            IConvertible i2 = c2 as IConvertible;
            float        f2 = i2.ToSingle(null);
            if (f2 != Int32.MaxValue)
            {
                TestLibrary.TestFramework.LogError("005", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 10
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Using the Format string \"F\"");

        try
        {
            e_test e3 = e_test.itemA;
            string s3 = e3.ToString("F");
            if (s3 != "itemA")
            {
                TestLibrary.TestFramework.LogError("005", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 11
0
    public bool NegTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("NegTest1: Set the format string argument as a invalid value ");

        try
        {
            e_test e2 = e_test.itemC;
            string s2 = e2.ToString("H");
            TestLibrary.TestFramework.LogError("101", "The ArgumentException was not thrown as expected");
            retVal = false;
        }
        catch (FormatException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("102", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 12
0
    public bool PosTest5()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest5: Using the empty string as the argument");

        try
        {
            e_test e3 = e_test.itemA;
            string s3 = e3.ToString("");
            if (s3 != "itemA")
            {
                TestLibrary.TestFramework.LogError("009", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 13
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Convert a enum to int64, the value of which is Int32.Maximal ");

        try
        {
            e_test e3 = e_test.itemA;
            long   l3 = (e3 as IConvertible).ToInt64(null);
            if (l3 != Int32.MaxValue)
            {
                TestLibrary.TestFramework.LogError("005", "The result is not the value as expected");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
            retVal = false;
        }

        return(retVal);
    }