本文整理汇总了C#中IFakeObjectCall类的典型用法代码示例。如果您正苦于以下问题:C# IFakeObjectCall类的具体用法?C# IFakeObjectCall怎么用?C# IFakeObjectCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFakeObjectCall类属于命名空间,在下文中一共展示了IFakeObjectCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Matches
/// <summary>
/// Matches the specified call against the expression.
/// </summary>
/// <param name="call">The call to match.</param>
/// <returns>True if the call is matched by the expression.</returns>
public virtual bool Matches(IFakeObjectCall call)
{
Guard.AgainstNull(call, "call");
return this.InvokesSameMethodOnTarget(call.FakedObject.GetType(), call.Method, this.Method)
&& this.ArgumentsMatches(call.Arguments);
}
示例2: GetCanceledTokens
private static IEnumerable<CancellationToken> GetCanceledTokens(IFakeObjectCall call)
{
return call.Method.GetParameters()
.Select((param, index) => new { param, index })
.Where(x => x.param.ParameterType == typeof(CancellationToken))
.Select(x => (CancellationToken)call.Arguments[x.index])
.Where(token => token.IsCancellationRequested);
}
示例3: OnIsApplicableTo
protected override bool OnIsApplicableTo(IFakeObjectCall fakeObjectCall)
{
return
this.argumentsPredicate(fakeObjectCall.Arguments) &&
(this.ApplicableToMembersWithReturnType == null
|| (this.ApplicableToMembersWithReturnType == fakeObjectCall.Method.ReturnType)
|| (this.ApplicableToAllNonVoidReturnTypes && fakeObjectCall.Method.ReturnType != typeof(void)));
}
示例4: GetFakeErrors
private void GetFakeErrors(IFakeObjectCall obj)
{
var errors = (Dictionary<string, ErrorRecord>)obj.Arguments[2];
for (var i = 0; i < _given.ExpectedErrorCount; i++)
{
errors.Add(i.ToString(), Random.ErrorRecord);
}
}
示例5: GetDescription
/// <summary>
/// Gets a human readable description of the specified
/// fake object call.
/// </summary>
/// <param name="call">The call to get a description for.</param>
/// <returns>A description of the call.</returns>
public string GetDescription(IFakeObjectCall call)
{
var builder = new StringBuilder();
builder
.Append(this.fakeManagerAccessor.GetFakeManager(call.FakedObject).FakeObjectType)
.Append(".");
AppendMethodName(builder, call.Method);
this.AppendArgumentsList(builder, call);
return builder.ToString();
}
示例6: OnIsApplicableTo
protected override bool OnIsApplicableTo(IFakeObjectCall fakeObjectCall)
{
return this.ExpressionMatcher.Matches(fakeObjectCall);
}
示例7: OnIsApplicableTo
protected abstract bool OnIsApplicableTo(IFakeObjectCall fakeObjectCall);
示例8: IsApplicableTo
/// <summary>
/// Gets if this rule is applicable to the specified call.
/// </summary>
/// <param name="fakeObjectCall">The call to validate.</param>
/// <returns>True if the rule applies to the call.</returns>
public virtual bool IsApplicableTo(IFakeObjectCall fakeObjectCall)
{
return this.wherePredicates.All(x => x.Item1.Invoke(fakeObjectCall))
&& this.OnIsApplicableTo(fakeObjectCall);
}
示例9: IsApplicableTo
public bool IsApplicableTo(IFakeObjectCall fakeObjectCall)
{
return this.IsPropertySetter(fakeObjectCall) || this.IsPropertyGetter(fakeObjectCall);
}
示例10: MakeEqualCopy
private static IFakeObjectCall MakeEqualCopy(IFakeObjectCall call)
{
var copy = A.Fake<IFakeObjectCall>();
A.CallTo(() => copy.Method).Returns(call.Method);
A.CallTo(() => copy.Arguments).Returns(call.Arguments);
A.CallTo(() => copy.FakedObject).Returns(call.FakedObject);
return copy;
}
示例11: GetOutputArgumentsForCall
private static IEnumerable<object> GetOutputArgumentsForCall(IFakeObjectCall call)
{
return
from valueAndParameterInfo in call.Method.GetParameters().Zip(call.Arguments.AsEnumerable())
where valueAndParameterInfo.Item1.ParameterType.IsByRef
select valueAndParameterInfo.Item2;
}
示例12: GetOutputArgumentsForCall
private static IEnumerable<object> GetOutputArgumentsForCall(IFakeObjectCall call)
{
return
from valueAndParameterInfo in call.Method.GetParameters().Zip(
call.Arguments.AsEnumerable(),
(parameter, argument) => new { parameter.ParameterType, Argument = argument })
where valueAndParameterInfo.ParameterType.IsByRef
select valueAndParameterInfo.Argument;
}
示例13: GetArgumentValueInfos
private static ArgumentValueInfo[] GetArgumentValueInfos(IFakeObjectCall call)
{
return
(from argument in
call.Method.GetParameters()
.Zip(call.Arguments, (parameter, value) => new { parameter.Name, Value = value })
select new ArgumentValueInfo
{
ArgumentName = argument.Name,
ArgumentValue = argument.Value
}).ToArray();
}
示例14: OnIsApplicableTo
protected override bool OnIsApplicableTo(IFakeObjectCall fakeObjectCall)
{
return
this.argumentsPredicate(fakeObjectCall.Arguments) &&
(this.ApplicableToMembersWithReturnType == null || this.ApplicableToMembersWithReturnType.Equals(fakeObjectCall.Method.ReturnType));
}
示例15: IsObjetMethod
private static bool IsObjetMethod(IFakeObjectCall fakeObjectCall)
{
return ObjectMethodsMethodHandles.Contains(fakeObjectCall.Method.MethodHandle);
}