Пример #1
0
    public bool PosTest2()
    {
        bool retVal = false;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Call Dispose with explicitDisposing set to false");

        try
        {
            TestWaitHandle1 handle = new TestWaitHandle1();

            // Dispose only unmanaged resources.
            // (DoDispose just calls Dispose)
            handle.DoDispose(false);

            // Do a waitone on the handle, should get ObjectDisposedException
            handle.WaitOne(c_DEFAULT_WAIT_TIME);

            // if we get here, it wasn't disposed of, error
            TestLibrary.TestFramework.LogError("003", "handle.Dispose(false) did not dispose of the handle");
            retVal = false;
        }
        catch (ObjectDisposedException)
        {
            // swallow it, this is where we wanted to go
            retVal = true;
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }
        return(retVal);
    }
Пример #2
0
    public bool PosTest1()
    {
        bool retVal = false;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call Dispose with explicitDisposing set to true");

        try
        {
            // Create a WaitHandle-derived object
            TestWaitHandle1 handle = new TestWaitHandle1();

            // Dispose both managed and
            // unmanaged resources (DoDispose just calls
            // Dispose)
            handle.DoDispose(true);

            // Do a waitone on the handle, should immediately throw
            // ObjectDisposedException
            handle.WaitOne(c_DEFAULT_WAIT_TIME);

            // if we get here, it wasn't disposed of, error
            TestLibrary.TestFramework.LogError("001", "handle.Dispose(true) did not dispose of the handle");
            retVal = false;
        }
        catch (ObjectDisposedException)
        {
            // swallow it, this is where we wanted to go
            retVal = true;
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Пример #3
0
    public bool PosTest1()
    {
        bool retVal = false;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call Dispose with explicitDisposing set to true");

        try
        {
            // Create a WaitHandle-derived object
            TestWaitHandle1 handle = new TestWaitHandle1();

            // Dispose both managed and 
            // unmanaged resources (DoDispose just calls
            // Dispose)
            handle.DoDispose(true);

            // Do a waitone on the handle, should immediately throw
            // ObjectDisposedException
            handle.WaitOne(c_DEFAULT_WAIT_TIME);

            // if we get here, it wasn't disposed of, error
            TestLibrary.TestFramework.LogError("001", "handle.Dispose(true) did not dispose of the handle");
            retVal = false;
        }
        catch (ObjectDisposedException)
        {
            // swallow it, this is where we wanted to go
            retVal = true;
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Пример #4
0
    public bool PosTest2()
    {
        bool retVal = false;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Call Dispose with explicitDisposing set to false");

        try
        {
            TestWaitHandle1 handle = new TestWaitHandle1();

            // Dispose only unmanaged resources.
            // (DoDispose just calls Dispose)
            handle.DoDispose(false);

            // Do a waitone on the handle, should get ObjectDisposedException
            handle.WaitOne(c_DEFAULT_WAIT_TIME);

            // if we get here, it wasn't disposed of, error
            TestLibrary.TestFramework.LogError("003", "handle.Dispose(false) did not dispose of the handle");
            retVal = false;
        }
        catch (ObjectDisposedException)
        {
            // swallow it, this is where we wanted to go
            retVal = true;
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }
        return retVal;
    }