本文整理汇总了C#中IExecutionContext.When方法的典型用法代码示例。如果您正苦于以下问题:C# IExecutionContext.When方法的具体用法?C# IExecutionContext.When怎么用?C# IExecutionContext.When使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExecutionContext
的用法示例。
在下文中一共展示了IExecutionContext.When方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
private void Setup(out IExecutionContext context, out IDocument[] documents, out Dictionary<IDocument, IDictionary<string, object>> cloneDictionary, params string[] pathArray)
{
documents = pathArray.Select(x =>
{
IDocument document = Substitute.For<IDocument>();
document.Source.Returns(x);
document.GetStream().Returns(File.OpenRead(x));
return document;
}).ToArray();
var tempDictionary = new Dictionary<IDocument, IDictionary<string, object>>();
cloneDictionary = tempDictionary;
context = Substitute.For<IExecutionContext>();
context
.When(x => x.GetDocument(Arg.Any<IDocument>(), Arg.Any<IEnumerable<KeyValuePair<string, object>>>()))
.Do(x =>
{
var document = x.Arg<IDocument>();
var newMetadata = x.Arg<IEnumerable<KeyValuePair<string, object>>>();
var oldMetadata = document.Metadata.ToDictionary(y => y.Key, y => y.Value);
foreach (var m in newMetadata) // overriding the old metadata like Document would do it.
{
oldMetadata[m.Key] = m.Value;
}
tempDictionary[document] = oldMetadata;
});
}