Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3946480
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:08:17+00:00 2026-05-20T01:08:17+00:00

Has anyone tried this? I like moq and i like what pex is doing,

  • 0

Has anyone tried this?

I like moq and i like what pex is doing, but haven’t tried them together. I’d prefer to use moq over moles in most cases I think but am curious to see if anyone has hit roadblocks?

Do they play nice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:08:18+00:00Added an answer on May 20, 2026 at 1:08 am

    Although I haven’t tried, Pex and Moq should get along like old friends.

    While the interception techniques between Pex and Moq are different (Pex uses the ProfilerAPI to interpret MSIL instructions; Moq uses DynamicProxy to dynamically derive classes) there are references in the Moq source code that suggest it was designed to prevent re-entrance problems where Pex would interfere with Moq.

    According to the original research paper for Pex, you can decorate your code with attributes that control when the Pex rewriter is used.

    From the Moq source code:

    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 is defined as:

     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();
            }
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might seem like an odd request but I'd like to use jQuery's Selectable
Has anyone tried using the NHibernate Velocity L2 cache provider against the Azure AppFabric
Has anyone tried to build an e-commerce site atop MS Dynamics, using the new
Has anyone tried to back up a SharePoint web application using forms based authentication
Has anyone tried automatic Java to C++ conversion for speed improvements? Is it a
Has anyone tried out working with the Delete and update command of SPDataSource used
Has anyone tried taking a video from the camera and then using the video
Has Anyone tried using PDF in iPad Application, using CGPDf functions. I have used
Does LINQPad work with Oracle? Has anyone tried? What do you suggest?
Has anyone successfully tried minifying AND concatenating all the jqGrid locale files so that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.