本文整理汇总了C#中IMessageSink.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# IMessageSink.Publish方法的具体用法?C# IMessageSink.Publish怎么用?C# IMessageSink.Publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMessageSink
的用法示例。
在下文中一共展示了IMessageSink.Publish方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunTestModel
private void RunTestModel(TestModel testModel, IMessageSink messageSink, IProgressMonitor progressMonitor, double totalWork)
{
double workUnitsPerStep = totalWork / (1 + testModel.RootTest.Children.Count);
TestStep rootTestStep = new TestStep(testModel.RootTest, null);
messageSink.Publish(new TestStepStartedMessage()
{
Step = new TestStepData(rootTestStep)
});
foreach (Test test in testModel.RootTest.Children)
{
if (progressMonitor.IsCanceled)
return;
TestStep testStep = new TestStep(test, rootTestStep);
messageSink.Publish(new TestStepStartedMessage()
{
Step = new TestStepData(testStep)
});
messageSink.Publish(new TestStepLogStreamWriteMessage()
{
StepId = testStep.Id,
StreamName = MarkupStreamNames.Warnings,
Text = FallbackExplanation
});
messageSink.Publish(new TestStepFinishedMessage()
{
StepId = testStep.Id,
Result = new TestResult(TestOutcome.Ignored)
});
progressMonitor.Worked(workUnitsPerStep);
}
messageSink.Publish(new TestStepFinishedMessage()
{
StepId = rootTestStep.Id,
Result = new TestResult(TestOutcome.Skipped)
});
progressMonitor.Worked(workUnitsPerStep);
}
示例2: PublishTestModel
/// <summary>
/// Publishes the contents of the test model to a message sink as test
/// and annotation discovered messages.
/// </summary>
/// <param name="testModel">The test model to publish.</param>
/// <param name="messageSink">The message sink.</param>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="testModel"/>
/// or <paramref name="messageSink"/> is null.</exception>
public static void PublishTestModel(TestModel testModel, IMessageSink messageSink)
{
if (testModel == null)
throw new ArgumentNullException("testModel");
if (messageSink == null)
throw new ArgumentNullException("messageSink");
foreach (Annotation annotation in testModel.Annotations)
{
messageSink.Publish(new AnnotationDiscoveredMessage()
{
Annotation = new AnnotationData(annotation)
});
}
foreach (Test test in testModel.AllTests)
{
messageSink.Publish(new TestDiscoveredMessage()
{
Test = new TestData(test, true),
ParentTestId = test.Parent != null ? test.Parent.Id : null
});
}
}
示例3: PublishTestModelFromFiles
private TestModel PublishTestModelFromFiles(IEnumerable<FileInfo> files, IMessageSink messageSink, IProgressMonitor progressMonitor)
{
TestModel testModel = new TestModel();
foreach (FileInfo file in files)
{
if (progressMonitor.IsCanceled)
return null;
messageSink.Publish(new AnnotationDiscoveredMessage()
{
Annotation = new AnnotationData(AnnotationType.Warning,
new CodeLocation(file.FullName, 0, 0),
CodeReference.Unknown,
string.Format("File '{0}' is not supported by any installed test framework. It will be ignored.", file.Name), null)
});
Test fileTest = CreateTest(file.Name, null);
fileTest.Metadata.Add(MetadataKeys.File, file.FullName);
testModel.RootTest.AddChild(fileTest);
progressMonitor.Worked(1);
}
TestModelSerializer.PublishTestModel(testModel, messageSink);
return testModel;
}