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


C# ITestContext.Error方法代码示例

本文整理汇总了C#中ITestContext.Error方法的典型用法代码示例。如果您正苦于以下问题:C# ITestContext.Error方法的具体用法?C# ITestContext.Error怎么用?C# ITestContext.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITestContext的用法示例。


在下文中一共展示了ITestContext.Error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckConfiguration

        private static void CheckConfiguration(ITestContext context)
        {
            // SitecoreInfo contains configuration, version and defaults
              var sitecoreInfo = context.SitecoreInfo;

              // showconfig.xml combined with web.config
              var configuration = sitecoreInfo.Configuration;
              if (configuration.SelectSingleElement("/configuration/sitecore") == null)
              {
            context.Error("The configuration is broken - missing <sitecore>...</sitecore> element");

            return;
              }

              var pipeline = sitecoreInfo.GetPipeline("httpRequestBegin");
              if (pipeline == null)
              {
            context.Error("The httpRequestBegin pipeline is not registered");

            return;
              }

              // check specific processor in httpRequestBegin pipeline
              var executeRequestType = TypeRef.Parse("Sitecore.Pipelines.HttpRequest.ExecuteRequest, Sitecore.Kernel");
              var executeRequest = pipeline.Processors.FirstOrDefault(x => x.Type == executeRequestType);
              if (executeRequest == null)
              {
            context.Warning("The {0} processor is missing which potentially can be configuration error", executeRequestType);
              }

              // download defaults for the given Sitecore version from cloud
              var defaults = sitecoreInfo.SitecoreDefaults;

              // check all default processors
              var defaultPipeline = defaults.GetPipeline("httpRequestBegin");
              Assert.IsNotNull(defaultPipeline, "The default httpRequestBegin pipeline cannot be null");

              foreach (var defaultProcessor in defaultPipeline.Processors)
              {
            Assert.IsNotNull(defaultProcessor, "The default processor in httpRequestBegin pipeline cannot be null");

            if (defaultProcessor.Type == executeRequestType)
            {
              // we already checked that manually
              continue;
            }

            var actualProcessor = pipeline.Processors.FirstOrDefault(x => x.Type == defaultProcessor.Type);
            if (actualProcessor == null)
            {
              context.Warning("The {0} processor is missing which potentially can be configuration error", defaultProcessor.Type);
            }
              }
        }
开发者ID:Sitecore,项目名称:Sitecore-Diagnostics-Toolset,代码行数:54,代码来源:SampleTest.cs

示例2: CheckWebDatabase

        private static void CheckWebDatabase(ITestContext context)
        {
            var web = context.Databases.Sql["web"];
              if (web == null)
              {
            return;
              }

              // create read item context to instantiate caches - they will be destroyed when it is disposed
              using (var items = web.Items.CreateContext())
              {
            // LinqToSql count how many home items in web db (https://github.com/Sitecore/Sitecore.Diagnostics.SqlDataProvider)
            var homeItemsCount = items.GetItems().Count(x => x.Name == "Home");
            if (homeItemsCount == 0)
            {
              context.Error("The /sitecore/content/Home item is missing");
            }

            // lets validate workflows (custom lightweight data provider Sitecore.DiagnosticsToolset.Resources.Database.dll)
            var workflowsRoot = items.GetItem(ItemIDs.WorkflowRoot, new GetItemOptions { LoadChildren = true, LoadDescendants = false });
            if (workflowsRoot == null)
            {
              context.Error("The /sitecore/system/workflows item is missing");

              return;
            }

            foreach (var workflow in workflowsRoot.Children)
            {
              var initialStepId = workflow.Fields.Shared["Initial"];
              if (string.IsNullOrEmpty(initialStepId))
              {
            context.Error("The {0} workflow does not have initial workflow step set up", workflow.ItemPath);
              }
            }
              }
        }
开发者ID:Sitecore,项目名称:Sitecore-Diagnostics-Toolset,代码行数:37,代码来源:SampleTest.cs


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