当前位置: 首页>>代码示例>>C#>>正文


C# UnitTest.GetOptions方法代码示例

本文整理汇总了C#中MonoDevelop.NUnit.UnitTest.GetOptions方法的典型用法代码示例。如果您正苦于以下问题:C# UnitTest.GetOptions方法的具体用法?C# UnitTest.GetOptions怎么用?C# UnitTest.GetOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MonoDevelop.NUnit.UnitTest的用法示例。


在下文中一共展示了UnitTest.GetOptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunUnitTest

		internal UnitTestResult RunUnitTest (UnitTest test, string suiteName, string testName, TestContext testContext)
		{
			ExternalTestRunner runner = (ExternalTestRunner) Runtime.ProcessService.CreateExternalProcessObject (typeof(ExternalTestRunner), testContext.ExecutionContext);
			LocalTestMonitor localMonitor = new LocalTestMonitor (testContext, runner, test, suiteName, testName != null);
			
			ITestFilter filter = null;
			
			if (testName != null) {
				filter = new TestNameFilter (suiteName + "." + testName);
			} else {
				NUnitCategoryOptions categoryOptions = (NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions));
				if (categoryOptions.EnableFilter && categoryOptions.Categories.Count > 0) {
					string[] cats = new string [categoryOptions.Categories.Count];
					categoryOptions.Categories.CopyTo (cats, 0);
					filter = new CategoryFilter (cats);
					if (categoryOptions.Exclude)
						filter = new NotFilter (filter);
				}
			}
			
			RunData rd = new RunData ();
			rd.Runner = runner;
			rd.Test = this;
			rd.LocalMonitor = localMonitor;
			testContext.Monitor.CancelRequested += new TestHandler (rd.Cancel);
			
			UnitTestResult result;
			
			try {
				if (string.IsNullOrEmpty (AssemblyPath)) {
					string msg = GettextCatalog.GetString ("Could not get a valid path to the assembly. There may be a conflict in the project configurations.");
					throw new Exception (msg);
				}
				System.Runtime.Remoting.RemotingServices.Marshal (localMonitor, null, typeof (IRemoteEventListener));
				result = runner.Run (localMonitor, filter, AssemblyPath, suiteName, new List<string> (SupportAssemblies));
				if (testName != null)
					result = localMonitor.SingleTestResult;
			} catch (Exception ex) {
				if (!localMonitor.Canceled) {
					LoggingService.LogError (ex.ToString ());
					if (localMonitor.RunningTest != null) {
						RuntimeErrorCleanup (testContext, localMonitor.RunningTest, ex);
					} else {
						testContext.Monitor.ReportRuntimeError (null, ex);
						throw ex;
					}
					result = UnitTestResult.CreateFailure (ex);
				} else {
					result = UnitTestResult.CreateFailure (GettextCatalog.GetString ("Canceled"), null);
				}
			} finally {
				testContext.Monitor.CancelRequested -= new TestHandler (rd.Cancel);
				runner.Dispose ();
				System.Runtime.Remoting.RemotingServices.Disconnect (localMonitor);
			}
			
			return result;
		}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:58,代码来源:NUnitAssemblyTestSuite.cs

示例2: RunUnitTest

		internal UnitTestResult RunUnitTest (UnitTest test, string suiteName, string pathName, string testName, TestContext testContext)
		{
			var runnerExe = GetCustomConsoleRunnerCommand ();
			if (runnerExe != null)
				return RunWithConsoleRunner (runnerExe, test, suiteName, pathName, testName, testContext);

			ExternalTestRunner runner = (ExternalTestRunner)Runtime.ProcessService.CreateExternalProcessObject (typeof(ExternalTestRunner), testContext.ExecutionContext, UserAssemblyPaths);
			LocalTestMonitor localMonitor = new LocalTestMonitor (testContext, test, suiteName, testName != null);

			ITestFilter filter = null;
			if (test != null) {
				if (test is UnitTestGroup) {
					var categoryOptions = (NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions));
					if (categoryOptions.EnableFilter && categoryOptions.Categories.Count > 0) {
						string[] cats = new string [categoryOptions.Categories.Count];
						categoryOptions.Categories.CopyTo (cats, 0);
						filter = new CategoryFilter (cats);
						if (categoryOptions.Exclude)
							filter = new NotFilter (filter);
					} else {
						filter = new TestNameFilter (CollectTests ((UnitTestGroup)test));
					}
				} else {
					filter = new TestNameFilter (test.TestId);
				}
			}

			RunData rd = new RunData ();
			rd.Runner = runner;
			rd.Test = this;
			rd.LocalMonitor = localMonitor;
			testContext.Monitor.CancelRequested += new TestHandler (rd.Cancel);

			UnitTestResult result;
			var crashLogFile = Path.GetTempFileName ();

			try {
				if (string.IsNullOrEmpty (AssemblyPath)) {
					string msg = GettextCatalog.GetString ("Could not get a valid path to the assembly. There may be a conflict in the project configurations.");
					throw new Exception (msg);
				}
				System.Runtime.Remoting.RemotingServices.Marshal (localMonitor, null, typeof (IRemoteEventListener));

				string testRunnerAssembly, testRunnerType;
				GetCustomTestRunner (out testRunnerAssembly, out testRunnerType);

				result = runner.Run (localMonitor, filter, AssemblyPath, "", new List<string> (SupportAssemblies), testRunnerType, testRunnerAssembly, crashLogFile);
				if (testName != null)
					result = localMonitor.SingleTestResult;
				
				ReportCrash (testContext, crashLogFile);
				
			} catch (Exception ex) {
				if (ReportCrash (testContext, crashLogFile)) {
					result = UnitTestResult.CreateFailure (GettextCatalog.GetString ("Unhandled exception"), null);
				}
				else if (!localMonitor.Canceled) {
					LoggingService.LogError (ex.ToString ());
					if (localMonitor.RunningTest != null) {
						RuntimeErrorCleanup (testContext, localMonitor.RunningTest, ex);
					} else {
						testContext.Monitor.ReportRuntimeError (null, ex);
						throw;
					}
					result = UnitTestResult.CreateFailure (ex);
				} else {
					result = UnitTestResult.CreateFailure (GettextCatalog.GetString ("Canceled"), null);
				}
			} finally {
				File.Delete (crashLogFile);
				testContext.Monitor.CancelRequested -= new TestHandler (rd.Cancel);
				runner.Dispose ();
				System.Runtime.Remoting.RemotingServices.Disconnect (localMonitor);
			}
			
			return result;
		}
开发者ID:riverans,项目名称:monodevelop,代码行数:77,代码来源:NUnitAssemblyTestSuite.cs

示例3: NUnitOptionsWidget

		public NUnitOptionsWidget (Properties customizationObject)
		{
			Build ();
			test =  ((Properties)customizationObject).Get<UnitTest> ("UnitTest");
			config =  ((Properties)customizationObject).Get<string> ("Config");
			options = localOptions = (NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions), config);
			
			store = new TreeStore (typeof(string));
			categoryTree.Model = store;
			categoryTree.HeadersVisible = false;
			
			CellRendererText tr = new CellRendererText ();
			tr.Editable = true;
			tr.Edited += new EditedHandler (OnCategoryEdited);
			textColumn = new TreeViewColumn ();
			textColumn.Title = GettextCatalog.GetString ("Category");
			textColumn.PackStart (tr, false);
			textColumn.AddAttribute (tr, "text", 0);
			textColumn.Expand = true;
			categoryTree.AppendColumn (textColumn);
			
			if (test.Parent != null)
				useParentCheck.Active = !test.HasOptions (typeof(NUnitCategoryOptions), config);
			else {
				useParentCheck.Active = false;
				useParentCheck.Sensitive = false;
			}
			
			if (!options.EnableFilter)
				noFilterRadio.Active = true;
			else if (options.Exclude)
				excludeRadio.Active = true;
			else
				includeRadio.Active = true;

			Fill ();
			
			noFilterRadio.Toggled += new EventHandler (OnFilterToggled);
			includeRadio.Toggled += new EventHandler (OnFilterToggled);
			excludeRadio.Toggled += new EventHandler (OnFilterToggled);
			useParentCheck.Toggled += new EventHandler (OnToggledUseParent);
			addButton.Clicked += new EventHandler (OnAddCategory);
			removeButton.Clicked += new EventHandler (OnRemoveCategory);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:44,代码来源:NUnitOptionsPanel.cs

示例4: RunUnitTest

        internal UnitTestResult RunUnitTest(UnitTest test, string suiteName, TestContext testContext)
        {
            ExternalTestRunner runner = (ExternalTestRunner) Runtime.ProcessService.CreateExternalProcessObject (typeof(ExternalTestRunner), false);
            LocalTestMonitor localMonitor = new LocalTestMonitor (testContext, runner, test, suiteName);

            IFilter filter = null;

            NUnitCategoryOptions categoryOptions = (NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions));
            if (categoryOptions.EnableFilter && categoryOptions.Categories.Count > 0) {
                string[] cats = new string [categoryOptions.Categories.Count];
                categoryOptions.Categories.CopyTo (cats, 0);
                filter = new CategoryFilter (cats, categoryOptions.Exclude);
            }

            RunData rd = new RunData ();
            rd.Runner = runner;
            rd.Test = this;
            testContext.Monitor.CancelRequested += new TestHandler (rd.Cancel);

            UnitTestResult result;

            try {
                TestResult res = runner.Run (localMonitor, filter, AssemblyPath, suiteName, null);
                result = localMonitor.GetLocalTestResult (res);
            } catch (Exception ex) {
                Console.WriteLine (ex);
                if (localMonitor.RunningTest != null) {
                    RuntimeErrorCleanup (testContext, localMonitor.RunningTest, ex);
                } else {
                    testContext.Monitor.ReportRuntimeError (null, ex);
                    throw ex;
                }
                result = UnitTestResult.CreateFailure (ex);
            } finally {
                testContext.Monitor.CancelRequested -= new TestHandler (rd.Cancel);
                runner.Dispose ();
            }

            return result;
        }
开发者ID:slluis,项目名称:monodevelop-prehistoric,代码行数:40,代码来源:NUnitAssemblyTestSuite.cs


注:本文中的MonoDevelop.NUnit.UnitTest.GetOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。