public bool NegTest2()
    {
        bool retVal    = true;
        int  randValue = 0;

        TestLibrary.TestFramework.BeginScenario("NegTest2: Call DangerousRelease twice with one call DangerousAddRef for valid handle");

        try
        {
            randValue = TestLibrary.Generator.GetInt32(-55);
            SafeHandle handle  = new MySafeValidHandle(new IntPtr(randValue));
            bool       success = false;

            // if this object gets finalized it will throw an exception on the finalizer thread
            GC.SuppressFinalize(handle);

            handle.DangerousAddRef(ref success);
            if (!success)
            {
                TestLibrary.TestFramework.LogInformation("WARNING: Calling DangerousAddRef returns false");
            }

            handle.DangerousRelease();
            handle.DangerousRelease();
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("102.1", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation("WARNING: [LOCAL VARIABLES] randValue = " + randValue.ToString());
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

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

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call DangerousRelease after call DangerousAddRef for valid handle");

        try
        {
            SafeHandle handle  = new MySafeValidHandle();
            bool       success = false;

            handle.DangerousAddRef(ref success);
            if (!success)
            {
                TestLibrary.TestFramework.LogInformation("WARNING: Calling DangerousAddRef returns false");
            }

            handle.DangerousRelease();
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
    public bool PosTest2()
    {
        bool retVal    = true;
        int  randValue = 0;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Call DangerousRelease after call DangerousAddRef for valid handle");

        try
        {
            randValue = TestLibrary.Generator.GetInt32(-55);
            SafeHandle handle  = new MySafeValidHandle(new IntPtr(randValue));
            bool       success = false;

            handle.DangerousAddRef(ref success);
            if (!success)
            {
                TestLibrary.TestFramework.LogInformation("WARNING: Calling DangerousAddRef returns false");
            }

            handle.DangerousRelease();
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation("WARNING: [LOCAL VARIABLES] randValue = " + randValue.ToString());
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Ejemplo n.º 4
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call DangerousRelease after call DangerousAddRef for valid handle");

        try
        {
            SafeHandle handle = new MySafeValidHandle();
            bool success = false;

            handle.DangerousAddRef(ref success);
            if (!success)
            {
                TestLibrary.TestFramework.LogInformation("WARNING: Calling DangerousAddRef returns false");
            }

            handle.DangerousRelease();
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Ejemplo n.º 5
0
    public bool NegTest2()
    {
        bool retVal = true;
        int randValue = 0;

        TestLibrary.TestFramework.BeginScenario("NegTest2: Call DangerousRelease twice with one call DangerousAddRef for valid handle");

        try
        {
            randValue = TestLibrary.Generator.GetInt32(-55);
            SafeHandle handle = new MySafeValidHandle(new IntPtr(randValue));
            bool success = false;

            // if this object gets finalized it will throw an exception on the finalizer thread
            GC.SuppressFinalize(handle);

            handle.DangerousAddRef(ref success);
            if (!success)
            {
                TestLibrary.TestFramework.LogInformation("WARNING: Calling DangerousAddRef returns false");
            }

            handle.DangerousRelease();
            handle.DangerousRelease();
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("102.1", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation("WARNING: [LOCAL VARIABLES] randValue = " + randValue.ToString());
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Ejemplo n.º 6
0
    public bool PosTest5()
    {
        bool retVal = true;
        int randValue = 0;

        TestLibrary.TestFramework.BeginScenario("PosTest5: Call DangerousAddRef after call DangerousRelease for valid handle");

        try
        {
            randValue = TestLibrary.Generator.GetInt32(-55);
            SafeHandle handle = new MySafeValidHandle(new IntPtr(randValue));
            bool success = false;

            handle.DangerousAddRef(ref success);
            if (!success)
            {
                TestLibrary.TestFramework.LogInformation("WARNING: Calling DangerousAddRef returns false");
            }

            handle.DangerousRelease();

            handle.DangerousAddRef(ref success);
            if (!success)
            {
                TestLibrary.TestFramework.LogError("005.1", "Calling DangerousAddRef returns false after calling DangerousRelease");
            }

            handle.DangerousRelease();
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("005.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation("WARNING: [LOCAL VARIABLES] randValue = " + randValue.ToString());
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }