本文整理汇总了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);
}
}
}
示例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);
}
}
}
}