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


C# IMessageSink.Publish方法代码示例

本文整理汇总了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);
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:46,代码来源:FallbackTestDriver.cs

示例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
                });
            }
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:32,代码来源:TestModelSerializer.cs

示例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;
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:27,代码来源:FallbackTestDriver.cs


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