0
我想用我的sitecoreFakeDB代码创建单元测试下方显示:在它抛出一个异常的RenderingContext.Current检查的pageContext单元测试渲染上下文。页面的上下文抛出一个异常
using (Sitecore.FakeDb.Db db = new Sitecore.FakeDb.Db() { new Sitecore.FakeDb.DbItem("source") })
{
var contextItem = db.GetItem("/sitecore/content/source");
var args = new Sitecore.Pipelines.PipelineArgs();
using (RenderingContext.EnterContext(new Rendering(), contextItem))
{
var processor = new Mock<Sitecore.FakeDb.Pipelines.IPipelineProcessor>();
db.PipelineWatcher.Register("mypipeline", processor.Object);
Sitecore.Pipelines.CorePipeline.Run("mypipeline", args);
Xunit.Assert.NotNull(args.Current));
}
}