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 8199039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:05:25+00:00 2026-06-07T06:05:25+00:00

For unit testing, I’m using NUnit 2.6 and Moq 4.0. There’s a particular case

  • 0

For unit testing, I’m using NUnit 2.6 and Moq 4.0. There’s a particular case concerning virtual members where Moq’s proxy objects don’t relay method calls to the actual implementation (probably by design). For instance, if I had a class…

public class MyClass {
    protected virtual void A() {
        /* ... */
    }

    protected virtual void B(...) {
        /* ... */
    }
}

…and I use Moq to override GetSomethingElse‘s A() method in my test fixture…

var mock = new Mock<MyClass>();
mock.Protected().Setup("A").Callback(SomeSortOfCallback);

…using the mock’s A method works splendidly; however, if anything in said method would call not-mocked method B, the method will do nothing and/or return default values, even if an actual implementation exists in MyClass.

Is there a way to work around this? Am I using Moq wrong?

Thanks in advance,
Manny

  • 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-06-07T06:05:26+00:00Added an answer on June 7, 2026 at 6:05 am

    Set mock.CallBase = true and you should be good to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am unit-testing private methods in C# using NUnit. For example, my method (if
I'm doing some unit testing, and mocking some properties using Moq . Now, this
In unit testing, the setup method is used to create the objects needed for
When unit testing with JUnit, there are two similar methods, setUp() and setUpBeforeClass() .
I have been using unit testing for controllers with the 'poor man's' dependency injection
I'm unit testing my routes in ASP.NET MVC 2. I'm using MSTest and I'm
Unit testing is new to me, and I have this error I don't understand.
Should unit testing be run in debug or release mode? I am using Visual
How to write a unit testing case for custom spring validator implementation class .
Duplicate: Unit Testing the Views? Is there any way to unit test View? I

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.