Esempio n. 1
0
        private static bool RunTestMethod(Type implementationType, MethodInfo testMethod, bool printError)
        {
            Func <IWordsStatistics> createImpl = () => (IWordsStatistics)Activator.CreateInstance(implementationType);
            var testObj = new WordsStatistics_Tests {
                createStat = createImpl
            };

            testObj.SetUp();
            var timeout = GetTimeout(testMethod);

            try
            {
                Action test = () => testMethod.Invoke(testObj, new object[0]);
                if (timeout > 0)
                {
                    RunTestOnOwnThread(timeout, test);
                }
                else
                {
                    test();
                }
            }
            catch (Exception e)
            {
                if (printError)
                {
                    Console.WriteLine(e.InnerException);
                }
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
		private static bool RunTestMethod(Type implementationType, MethodInfo testMethod, bool printError)
		{
			Func<IWordsStatistics> createImpl = () => (IWordsStatistics)Activator.CreateInstance(implementationType);
			var testObj = new WordsStatistics_Tests { createStat = createImpl };
			testObj.SetUp();
			var timeout = GetTimeout(testMethod);
			try
			{
				Action test = () => testMethod.Invoke(testObj, new object[0]);
				if (timeout > 0)
					RunTestOnOwnThread(timeout, test);
				else test();
			}
			catch (Exception e)
			{
				if (printError)
					Console.WriteLine(e.InnerException);
				return false;
			}
			return true;
		}