本文整理汇总了C#中TestRunner.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# TestRunner.Subscribe方法的具体用法?C# TestRunner.Subscribe怎么用?C# TestRunner.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestRunner
的用法示例。
在下文中一共展示了TestRunner.Subscribe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanObserveTestRunner
public void CanObserveTestRunner()
{
var setUpCounter = 0;
var testCounter = 0;
var tearDownCounter = 0;
const int Start = 0;
const int Step = 7;
const int End = 135;
const string MailBoxName = "box";
using (var mailBox = new ProcessMailBox(MailBoxName, TimeSpan.FromMilliseconds(-1)))
{
using (var observer = new TestObserver(MailBoxName))
{
var list = new List<PerfTestResult>();
var runner = new TestRunner(i => setUpCounter++, () => testCounter++, () => tearDownCounter++, i => i / 2d, Start, Step, End);
var taskObserve = Task.Factory.StartNew(
() =>
{
runner.Subscribe(observer);
});
var taskMailBox = Task.Factory.StartNew(
() =>
{
for (int i = Start; i < End; i += Step)
{
list.Add((PerfTestResult)mailBox.Content);
}
});
Task.WaitAll(new[] { taskObserve, taskMailBox }, TimeSpan.FromSeconds(20)).Should().BeTrue();
var count = (int)Math.Ceiling((End - Start + 1) / (double)Step);
setUpCounter.Should().Be(count);
testCounter.Should().Be(count);
tearDownCounter.Should().Be(count);
var index = 0;
for (var i = Start; i < End; i += Step)
{
list[index++].Descriptor.Should().Be(i / 2d);
}
}
}
}
示例2: Start
public static void Start(StartParameters startParameters)
{
using (var testObserver = new TestObserver(startParameters.ChannelName))
{
var suite = AssemblyLoader.CreateInstance<PerfTestSuite>(
startParameters.SuiteAssembly, startParameters.SuiteType);
var subject = AssemblyLoader.CreateInstanceFullyQualifiedName(
startParameters.SubjectAssembly, startParameters.SubjectType);
var start = startParameters.Start;
var step = startParameters.Step;
var end = startParameters.End;
if (suite != null && subject != null)
{
var test = suite.Tests.First(x => x.TestMethodName == startParameters.TestMethod && x.TestedType == subject.GetType());
PerfTestResultFactory.Instance.Init(test.TestId);
var runner = new TestRunner(
delegate(int idx) { suite.SetUp(idx, subject); },
delegate { test.Test(subject); },
delegate { suite.TearDown(subject); },
delegate(int idx) { return suite.GetRunDescriptor(idx); },
string.IsNullOrEmpty(start) ? 0 : int.Parse(start),
string.IsNullOrEmpty(step) ? 1 : int.Parse(step),
string.IsNullOrEmpty(end) ? suite.DefaultTestCount : int.Parse(end),
startParameters.IgnoreFirstRunDueToJITting,
startParameters.TriggerGCBeforeEachTest);
runner.Subscribe(testObserver);
testObserver.OnCompleted();
}
else
{
testObserver.OnError(new Exception());
}
}
}