Although I have not tried, Pex and Moq should get along like old friends.
Pex Moq (Pex ProfilerAPI MSIL, Moq DynamicProxy ), Moq , , Pex Moq.
Pex, , Pex- .
Moq:
internal static MethodCall<T> Setup<T>(Mock mock, Expression<Action<T>> expression, Func<bool> condition) where T : class
{
return PexProtector.Invoke(() =>
{
var methodCall = expression.ToMethodCall();
var method = methodCall.Method;
var args = methodCall.Arguments.ToArray();
ThrowIfNotMember(expression, method);
ThrowIfCantOverride(expression, method);
var call = new MethodCall<T>(mock, condition, expression, method, args);
var targetInterceptor = GetInterceptor(methodCall.Object, mock);
targetInterceptor.AddCall(call, SetupKind.Other);
return call;
});
}
PexProtector :
internal sealed class __ProtectAttribute : Attribute
{
}
namespace Moq
{
[__Protect]
[DebuggerStepThrough]
internal static class PexProtector
{
public static void Invoke(Action action)
{
action();
}
public static T Invoke<T>(Func<T> function)
{
return function();
}
}
}