本文整理汇总了C#中IInterceptedFakeObjectCall.AsReadOnly方法的典型用法代码示例。如果您正苦于以下问题:C# IInterceptedFakeObjectCall.AsReadOnly方法的具体用法?C# IInterceptedFakeObjectCall.AsReadOnly怎么用?C# IInterceptedFakeObjectCall.AsReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInterceptedFakeObjectCall
的用法示例。
在下文中一共展示了IInterceptedFakeObjectCall.AsReadOnly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
/// <summary>
/// Applies an action to the call, might set a return value or throw
/// an exception.
/// </summary>
/// <param name="fakeObjectCall">The call to apply the interceptor to.</param>
public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
{
if (this.recorder.IsRecording)
{
this.wrappedRule.Apply(fakeObjectCall);
this.recorder.RecordCall(fakeObjectCall.AsReadOnly());
}
else
{
this.recorder.ApplyNext(fakeObjectCall);
}
}
示例2: foreach
void IFakeCallProcessor.Process(IInterceptedFakeObjectCall fakeObjectCall)
{
foreach (var listener in this.interceptionListeners)
{
listener.OnBeforeCallIntercepted(fakeObjectCall);
}
var ruleToUse =
(from rule in this.AllRules
where rule.Rule.IsApplicableTo(fakeObjectCall) && rule.HasNotBeenCalledSpecifiedNumberOfTimes()
select rule).First();
try
{
ApplyRule(ruleToUse, fakeObjectCall);
}
finally
{
var readonlyCall = fakeObjectCall.AsReadOnly();
this.RecordCall(readonlyCall);
foreach (var listener in this.interceptionListeners.Reverse())
{
listener.OnAfterCallIntercepted(readonlyCall, ruleToUse.Rule);
}
}
}