本文整理汇总了C#中ITest类的典型用法代码示例。如果您正苦于以下问题:C# ITest类的具体用法?C# ITest怎么用?C# ITest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITest类属于命名空间,在下文中一共展示了ITest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessTestCases
private int ProcessTestCases(ITest test, ITestCaseDiscoverySink discoverySink, TestConverter testConverter)
{
int cases = 0;
if (test.IsSuite)
{
foreach (ITest child in test.Tests)
cases += ProcessTestCases(child, discoverySink,testConverter);
}
else
{
try
{
#if LAUNCHDEBUGGER
Debugger.Launch();
#endif
TestCase testCase = testConverter.ConvertTestCase(test);
discoverySink.SendTestCase(testCase);
cases += 1;
}
catch (System.Exception ex)
{
testLog.SendErrorMessage("Exception converting " + test.TestName.FullName, ex);
}
}
return cases;
}
示例2: RunTest
protected static void RunTest(ITest test)
{
int loops = Calibrate(test, TimeSpan.FromMilliseconds(1000));
var sw = new Stopwatch();
GC.Collect();
GC.WaitForPendingFinalizers();
var c1 = GC.CollectionCount(0);
var c2 = GC.CollectionCount(1);
var c3 = GC.CollectionCount(2);
sw.Start();
test.DoTest(loops);
sw.Stop();
c1 = GC.CollectionCount(0) - c1;
c2 = GC.CollectionCount(1) - c2;
c3 = GC.CollectionCount(2) - c3;
var lps = (int)(loops / (sw.ElapsedMilliseconds / 1000.0));
Console.WriteLine("{0,-40} {1,20} loops/s, collections {2}/{3}/{4}",
test.GetType().Name, lps,
c1, c2, c3);
}
示例3: BuildStackTrace
private static string BuildStackTrace(Exception exception, ITest test, IEnumerable<string> traceMessages)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("SPECIFICATION:");
if (test.Properties.Contains(TestExtensions.MultilineNameProperty))
{
foreach (var line in ((string)test.Properties[TestExtensions.MultilineNameProperty]).Split('\n'))
sb.AppendLine(" " + line);
}
sb.AppendLine();
if (traceMessages.Count() > 0)
{
foreach (var line in traceMessages)
sb.AppendLine(line);
sb.AppendLine();
}
sb.AppendLine(GetStackTrace(exception));
for (Exception innerException = exception.InnerException; innerException != null; innerException = innerException.InnerException)
{
sb.Append(Environment.NewLine);
sb.Append("--");
sb.Append(innerException.GetType().Name);
sb.Append(Environment.NewLine);
sb.Append(GetStackTrace(innerException));
}
return sb.ToString();
}
示例4: TestUnitWithMetadata
/// <summary>
/// Initializes a new instance of the <see cref="TestUnitWithMetadata"/> class.
/// </summary>
/// <param name="testRun">The test run.</param>
/// <param name="test"></param>
/// <param name="assemblyName">Name of the assembly.</param>
/// <param name="children">The children.</param>
public TestUnitWithMetadata(TestRun testRun, ITest test, string assemblyName, List<TestUnitWithMetadata> children = null)
{
Children = children ?? new List<TestUnitWithMetadata>();
Test = new TestUnit(test, testRun, assemblyName);
Results = new List<TestResult>();
AttachedData = new TestUnitAttachedData();
}
示例5: AddCategories
public void AddCategories( ITest test )
{
if (test.Categories != null)
foreach (string name in test.Categories)
if (NUnitFramework.IsValidCategoryName(name))
Add(name);
}
示例6: Failed
public static ITestResult Failed(
ITest test,
string message,
Exception t)
{
return new SimpleTestResult(false, test.Name + ": " + message, t);
}
示例7: WriteTestFile
/// <summary>
/// Writes test info to a file
/// </summary>
/// <param name="test">The test to be written</param>
/// <param name="outputPath">Path to the file to which the test info is written</param>
public void WriteTestFile(ITest test, string outputPath)
{
using (StreamWriter writer = new StreamWriter(outputPath, false, Encoding.UTF8))
{
WriteTestFile(test, writer);
}
}
示例8: Queue
public static void Queue(
this IMessageBus messageBus,
ITest test,
Func<ITest, IMessageSinkMessage> createTestResultMessage,
CancellationTokenSource cancellationTokenSource)
{
Guard.AgainstNullArgument("messageBus", messageBus);
Guard.AgainstNullArgument("createTestResultMessage", createTestResultMessage);
Guard.AgainstNullArgument("cancellationTokenSource", cancellationTokenSource);
if (!messageBus.QueueMessage(new TestStarting(test)))
{
cancellationTokenSource.Cancel();
}
else
{
if (!messageBus.QueueMessage(createTestResultMessage(test)))
{
cancellationTokenSource.Cancel();
}
}
if (!messageBus.QueueMessage(new TestFinished(test, 0, null)))
{
cancellationTokenSource.Cancel();
}
}
示例9: TestStarted
/// <summary>
/// Forwards the TestStarted event to all listeners.
/// </summary>
/// <param name="test">The test that just started.</param>
public void TestStarted(ITest test)
{
System.Diagnostics.Debug.WriteLine(test.Name + " TEST STARTED");
System.Threading.Thread.Sleep(2000);
foreach (TestListener listener in listeners)
listener.TestStarted(test);
}
示例10: OrganizationService
public OrganizationService(ITest test)
{
if(test == null)
throw new ArgumentNullException("test");
this._test = test;
}
开发者ID:HansKindberg-Net,项目名称:WCF-Enabled-WebApplication-With-ConstructorInjection-Lab,代码行数:7,代码来源:OrganizationService.cs
示例11: AddAllCategories
public void AddAllCategories( ITest test )
{
AddCategories( test );
if ( test.IsSuite )
foreach( ITest child in test.Tests )
AddAllCategories( child );
}
示例12: NewTestResultSummaryEventArgs
public NewTestResultSummaryEventArgs(ITest test, ITestResult result, ITestOutcomeFilter outcomeFilter, ITestResultSummary summary)
{
Test = test;
Result = result;
OutcomeFilter = outcomeFilter;
Summary = summary;
}
示例13: RunTest
public static void RunTest(TestType type, int ThreadCount, CallbackFunction callBack, ITest target)
{
for (int i = 0; i < ThreadCount; i++)
{
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (object sender, DoWorkEventArgs e) =>
{
bool result = target.Test();
e.Result = result;
};
worker.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) =>
{
if (callBack != null)
{
if (e.Error != null)
{
callBack(type, (bool)e.Result);
}
else
{
callBack(type, false);
}
}
};
worker.RunWorkerAsync();
}
}
示例14: TestStarted
public void TestStarted(ITest test)
{
level++;
prefix = new string('>', level);
if(options.DisplayTestLabels == "On" || options.DisplayTestLabels == "All")
outWriter.WriteLine("{0} {1}", prefix, test.Name);
}
示例15: TestSuiteTreeNode
/// <summary>
/// Construct a TestNode given a TestResult
/// </summary>
public TestSuiteTreeNode( TestResult result )
: base(result.Test.TestName.Name)
{
this.test = result.Test;
this.result = result;
UpdateImageIndex();
}