dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Threading SuiteT


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/tests/runtime/System/Threading SuiteThreading.cs,NONE,1.1 TestAutoResetEvent.cs,NONE,1.1 TestManualResetEvent.cs,NONE,1.1 TestWaitHandle.cs,NONE,1.1
Date: Sat, 11 Jan 2003 01:36:05 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/Threading
In directory subversions:/tmp/cvs-serv5634/tests/runtime/System/Threading

Added Files:
        SuiteThreading.cs TestAutoResetEvent.cs 
        TestManualResetEvent.cs TestWaitHandle.cs 
Log Message:


Added unit tests for WaitHandles, AutoResetEvents and ManualResetEvents.


--- NEW FILE ---
/*
 * SuiteThreading.cs - Tests for the "System.Threading" namespace.
 *
 * Copyright (C) 2002  Free Software Foundation
 * 
 * Authors:  Thong Nguyen (address@hidden)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

using CSUnit;
using System;

public class SuiteThreading
{
        public static TestSuite Suite()
        {
                TestSuite suite = new TestSuite("Threading Tests");
                
                suite.AddTests(typeof(TestWaitHandle));
                suite.AddTests(typeof(TestManualResetEvent));
                suite.AddTests(typeof(TestAutoResetEvent));
                
                return suite;
        }
}

--- NEW FILE ---
/*
 * TestBoolean.cs - Tests for the "Boolean" class.
 *
 * Copyright (C) 2002  Free Software Foundation.
 *
 * Authors: Thong Nguyen (address@hidden)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

using CSUnit;
using System;
using System.Threading;

public class TestAutoResetEvent
        : TestCase
{
        private AutoResetEvent e1;

        public TestAutoResetEvent(String name)
                : base(name)
        {
        }

        protected override void Setup()
        {
        }

        protected override void Cleanup()
        {
        }

        public void TestWaitOne()
        {
                bool x;

                e1 = new AutoResetEvent(false);

                x = e1.WaitOne(10);

                AssertEquals("WaitOne(unset)", x, false);

                e1.Set();

                x = e1.WaitOne(10);

                AssertEquals("WaitOne(set)", x, true);

                // It should be reset now.

                x = e1.WaitOne(10);

                AssertEquals("WaitOne(set)", x, false);
        }
}

--- NEW FILE ---
/*
 * TestBoolean.cs - Tests for the "Boolean" class.
 *
 * Copyright (C) 2002  Free Software Foundation.
 *
 * Authors: Thong Nguyen (address@hidden)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

using CSUnit;
using System;
using System.Threading;

public class TestManualResetEvent
        : TestCase
{
        private ManualResetEvent e1;

        public TestManualResetEvent(String name)
                : base(name)
        {
        }

        protected override void Setup()
        {
        }

        protected override void Cleanup()
        {
        }

        public void TestWaitOne()
        {
                bool x;

                e1 = new ManualResetEvent(false);

                x = e1.WaitOne(10);

                AssertEquals("WaitOne(unset)", x, false);

                e1.Set();

                x = e1.WaitOne(10);

                AssertEquals("WaitOne(set)", x, true);

                // It should still be set.

                x = e1.WaitOne(10);

                AssertEquals("WaitOne(set)", x, true);
        }
}

--- NEW FILE ---
/*
 * TestBoolean.cs - Tests for the "Boolean" class.
 *
 * Copyright (C) 2002  Free Software Foundation.
 *
 * Authors: Thong Nguyen (address@hidden)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

using CSUnit;
using System;
using System.Threading;

public class TestWaitHandle
        : TestCase
{
        private ManualResetEvent e1, e2;

        public TestWaitHandle(String name)
                : base(name)
        {
        }

        protected override void Setup()
        {
        }

        protected override void Cleanup()
        {
        }

        public void TestWaitAny()
        {
                int x;

                e1 = new ManualResetEvent(false);
                e2 = new ManualResetEvent(false);

                x = WaitHandle.WaitAny(new WaitHandle[] {e1,e2}, 100,false);

                AssertEquals("WaitAny(unset, unset)", x, 
WaitHandle.WaitTimeout);

                e1.Set();

                x = WaitHandle.WaitAny(new WaitHandle[] {e1,e2},100, false);

                AssertEquals("WaitAny(set, unset)", x, 0);

                e1.Reset();
                e2.Set();

                x = WaitHandle.WaitAny(new WaitHandle[] {e1,e2},100, false);

                AssertEquals("WaitAny(set, unset)", x, 1);

                e1.Set();
                e2.Set();

                x = WaitHandle.WaitAny(new WaitHandle[] {e1,e2},100, false);

                AssertEquals("WaitAny(set, set)", x, 0);
        }

        public void TestWaitAll()
        {
                bool x;

                e1 = new ManualResetEvent(false);
                e2 = new ManualResetEvent(false);

                x = WaitHandle.WaitAll(new WaitHandle[] {e1,e2}, 100,false);

                AssertEquals("WaitAll(unset, unset)", x, false);

                e1.Set();

                x = WaitHandle.WaitAll(new WaitHandle[] {e1,e2},100, false);

                AssertEquals("WaitAll(set, unset)", x, false);

                e1.Reset();
                e2.Set();

                x = WaitHandle.WaitAll(new WaitHandle[] {e1,e2},100, false);

                AssertEquals("WaitAll(set, unset)", x, false);

                e1.Set();
                e2.Set();

                x = WaitHandle.WaitAll(new WaitHandle[] {e1,e2},100, false);

                AssertEquals("WaitAll(set, set)", x, true);
        }
}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]