本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}