本文整理汇总了C#中IInterceptedFakeObjectCall.SetReturnValue方法的典型用法代码示例。如果您正苦于以下问题:C# IInterceptedFakeObjectCall.SetReturnValue方法的具体用法?C# IInterceptedFakeObjectCall.SetReturnValue怎么用?C# IInterceptedFakeObjectCall.SetReturnValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInterceptedFakeObjectCall
的用法示例。
在下文中一共展示了IInterceptedFakeObjectCall.SetReturnValue方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
{
Guard.AgainstNull(fakeObjectCall, "fakeObjectCall");
var returnValue = ResolveReturnValue(fakeObjectCall);
fakeObjectCall.SetReturnValue(returnValue);
}
示例2: Apply
public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
{
Guard.AgainstNull(fakeObjectCall, nameof(fakeObjectCall));
var returnType = fakeObjectCall.Method.ReturnType;
if (typeof(Task).GetTypeInfo().IsAssignableFrom(returnType))
{
Task task;
if (returnType == typeof(Task))
{
task = TaskHelper.Canceled();
}
else
{
var taskResultType = returnType.GetTypeInfo().GetGenericArguments()[0];
task = TaskHelper.Canceled(taskResultType);
}
fakeObjectCall.SetReturnValue(task);
}
else
{
var token = GetCanceledTokens(fakeObjectCall).First();
token.ThrowIfCancellationRequested();
}
}
示例3: 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)
{
Guard.AgainstNull(fakeObjectCall, "fakeObjectCall");
var parameters = fakeObjectCall.Arguments.GetUnderlyingArgumentsArray();
var valueFromWrappedInstance = fakeObjectCall.Method.Invoke(this.wrappedObject, parameters);
fakeObjectCall.SetReturnValue(valueFromWrappedInstance);
}
示例4: TryHandleToString
private bool TryHandleToString(IInterceptedFakeObjectCall fakeObjectCall)
{
if (!fakeObjectCall.Method.MethodHandle.Equals(ObjectMethodsMethodHandles[1]))
{
return false;
}
fakeObjectCall.SetReturnValue("Faked {0}".FormatInvariant(this.FakeManager.FakeObjectType.FullName));
return true;
}
示例5: TryHandleGetHashCode
private bool TryHandleGetHashCode(IInterceptedFakeObjectCall fakeObjectCall)
{
if (!fakeObjectCall.Method.MethodHandle.Equals(ObjectMethodsMethodHandles[2]))
{
return false;
}
fakeObjectCall.SetReturnValue(this.FakeManager.GetHashCode());
return true;
}
示例6: TryHandleGetHashCode
private bool TryHandleGetHashCode(IInterceptedFakeObjectCall fakeObjectCall)
{
if (!IsSameMethod(fakeObjectCall.Method, ObjectMethods[2]))
{
return false;
}
fakeObjectCall.SetReturnValue(this.fakeManager.GetHashCode());
return true;
}
示例7: ApplyNext
/// <summary>
/// Applies the call if the call has been recorded.
/// </summary>
/// <param name="fakeObjectCall">The call to apply to from recording.</param>
public void ApplyNext(IInterceptedFakeObjectCall fakeObjectCall)
{
this.AssertThatCallQueueIsNotEmpty();
var callToApply = this.callQueue.Dequeue();
AssertThatMethodsMatches(fakeObjectCall, callToApply);
ApplyOutputArguments(fakeObjectCall, callToApply);
fakeObjectCall.SetReturnValue(callToApply.RecordedCall.ReturnValue);
callToApply.HasBeenApplied = true;
}
示例8: Apply
public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
{
if (this.IsPropertyGetter(fakeObjectCall))
{
fakeObjectCall.SetReturnValue(this.Value);
}
else
{
this.Value = fakeObjectCall.Arguments[0];
}
this.fakeManager.MoveRuleToFront(this);
}
示例9: Apply
public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
{
Guard.AgainstNull(fakeObjectCall, "fakeObjectCall");
if (this.IsPropertyGetter(fakeObjectCall))
{
fakeObjectCall.SetReturnValue(this.Value);
}
else
{
this.Value = fakeObjectCall.Arguments.Last();
}
this.fakeManager.MoveRuleToFront(this);
}
示例10: 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)
{
Guard.AgainstNull(fakeObjectCall, nameof(fakeObjectCall));
var parameters = fakeObjectCall.Arguments.GetUnderlyingArgumentsArray();
object valueFromWrappedInstance;
try
{
valueFromWrappedInstance = fakeObjectCall.Method.Invoke(this.wrappedObject, parameters);
}
catch (TargetInvocationException ex)
{
ex.InnerException?.Rethrow();
throw;
}
fakeObjectCall.SetReturnValue(valueFromWrappedInstance);
}
示例11: TryHandleEquals
private bool TryHandleEquals(IInterceptedFakeObjectCall fakeObjectCall)
{
if (!fakeObjectCall.Method.MethodHandle.Equals(ObjectMethodsMethodHandles[0]))
{
return false;
}
var argument = fakeObjectCall.Arguments[0] as ITaggable;
if (argument != null)
{
fakeObjectCall.SetReturnValue(argument.Tag.Equals(this.FakeManager));
}
else
{
fakeObjectCall.SetReturnValue(false);
}
return true;
}
示例12: Apply
public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
{
Guard.AgainstNull(fakeObjectCall, nameof(fakeObjectCall));
fakeObjectCall.SetReturnValue(fakeObjectCall.GetDefaultReturnValue());
}
示例13: Apply
public void Apply(IInterceptedFakeObjectCall fakeObjectCall)
{
var returnValue = ResolveReturnValue(fakeObjectCall);
fakeObjectCall.SetReturnValue(returnValue);
}