⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mocktestrunner.cs

📁 C#编写的网络爬虫程序 效率很高 很好用!
💻 CS
字号:
using System;
using System.IO;
using System.Threading;
using System.Collections;
using NUnit.Framework;
using NUnit.Core;
using NUnit.Mocks;

namespace NUnit.Tests.Core
{
	/// <summary>
	/// Summary description for MockTestRunner.
	/// </summary>
	public class MockTestRunner : DynamicMock
	{
		private Thread runnerThread;

		public MockTestRunner() : base( "MockTestRunner", typeof( TestRunner ) ) { }

		public MockTestRunner( string name ) : base( name, typeof( TestRunner ) ) { }

		public Thread RunnerThread
		{
			get { return runnerThread; }
		}

		public override object Call(string methodName, params object[] args)
		{
			switch ( methodName )
			{
				case "Run":
					return RunCall( args );
				default:
					return base.Call (methodName, args);
			}
		}

		private object RunCall( object[] args )
		{
			EventListener listener = (EventListener) args[0];

			try
			{
				listener.RunStarted( new Test[0] );
				base.Call( "Run", args );
				listener.RunFinished( new TestResult[0] );
			}
			catch( Exception e )
			{
				listener.RunFinished( e );
			}

			return null;
		}

		public override void Verify()
		{
			base.Verify();

			if ( LastException != null )
				throw LastException;

			if ( runnerThread != null )
				Assert.IsFalse( Thread.CurrentThread == runnerThread, "Run should execute on a different thread" );
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -