/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using NUnit.Framework; namespace Lucene.Net.Support { [TestFixture] public class TestThreadClass { [Test] public void Test() { Support.ThreadClass thread = new Support.ThreadClass(); //Compare Current Thread Ids Assert.IsTrue(Support.ThreadClass.Current().Instance.ManagedThreadId == System.Threading.Thread.CurrentThread.ManagedThreadId); //Compare instances of ThreadClass MyThread mythread = new MyThread(); mythread.Start(); while (mythread.Result == null) System.Threading.Thread.Sleep(1); Assert.IsTrue((bool)mythread.Result); Support.ThreadClass nullThread = null; Assert.IsTrue(nullThread == null); //test overloaded operator == with null values Assert.IsFalse(nullThread != null); //test overloaded operator != with null values } class MyThread : Support.ThreadClass { public object Result = null; public override void Run() { Result = Support.ThreadClass.Current() == this; } } } }