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

  • SEARCH
  • Home
  • 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 158375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:40:14+00:00 2026-05-11T10:40:14+00:00

In .net, unlike in Java, methods are not virtual by default. In order to

  • 0

In .net, unlike in Java, methods are not virtual by default. In order to use most mock object frameworks, you either have to mark the methods that you want to use on your mock as virtual on the `real’ object, or you have to have an interface that you can mock that the class under test will accept in lieu of the implementation.

It seems like bad form to go and mark every method as virtual, but it also seems like bad form to define an interface for every single class.

What is the best thing to do?

  • 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. 2026-05-11T10:40:14+00:00Added an answer on May 11, 2026 at 10:40 am

    My rule of thumb is to define the interface if I expect to have multiple implementations, either actual concrete application classes or a single application implementation and a fake implementation for unit testing. If I only expect a single implementation and the class doesn’t need faking (most don’t), then I’ll go the virtual method route and refactor to an interface as needed.

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

Sidebar

Ask A Question

Stats

  • Questions 217k
  • Answers 217k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Answers: Yes, it is possible. Yes, you can create them… May 12, 2026 at 11:25 pm
  • Editorial Team
    Editorial Team added an answer http://code.google.com/p/phpmvchelpers/wiki/script_serve This is what I was looking to accomplish, the… May 12, 2026 at 11:25 pm
  • Editorial Team
    Editorial Team added an answer The trick is to use XmlWriterSettings to specify the encoding… May 12, 2026 at 11:25 pm

Related Questions

Does anyone know if it possible to define the equivalent of a java custom
I have written a java axis2 1.4.1 web service and .net 3.5 WCF client
I'm building a desktop application right now that presents its human-readable output as XHTML
When I develop using Delphi I always call DataSet.CheckBrowseMode() to allow bound controls to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.