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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:54:24+00:00 2026-05-24T09:54:24+00:00

Can I execute the body of a virtual method that lives on an abstract

  • 0

Can I execute the body of a virtual method that lives on an abstract class which has been mocked using Rhino Mocks?

To be clear, I’m not trying to mock the behavior of the virtual method. I’m trying to /test/ the virtual method (on the mocked class).

Is this idea a blatant misuse of Rhino Mocks?

  • 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-24T09:54:26+00:00Added an answer on May 24, 2026 at 9:54 am

    Yes, that should be absolutely fine. I can’t say I’ve tried it, but I’d be very surprised if it failed.

    EDIT: I suspect you want the PartialMock method. Here’s an example:

    using System;
    using Rhino.Mocks;
    
    public abstract class Abstract
    {
        public virtual int Foo()
        {
            return Bar() * 2;
        }
    
        public abstract int Bar();        
    }
    
    class Test
    {
        static void Main(string[] args)
        {
            MockRepository repository = new MockRepository();
            Abstract mock = repository.PartialMock<Abstract>();
    
            using (repository.Record())
            {
                Expect.Call(mock.Bar()).Return(5);
            }
    
            Console.WriteLine(mock.Foo()); // Prints 10
        }
    }
    

    EDIT: Or in my first attempt at AAA:

    using System;
    using Rhino.Mocks;
    
    public abstract class Abstract
    {
        public virtual int Foo()
        {
            return Bar() * 2;
        }
    
        public abstract int Bar();        
    }
    
    class Test
    {
        static void Main(string[] args)
        {
            // Arrange
            Abstract mock = MockRepository.GeneratePartialMock<Abstract>();
            mock.Stub(action => action.Bar()).Return(5);
    
            // Act
            int result = mock.Foo();
    
            // Assert
            mock.AssertWasCalled(x => x.Bar());
            // And assert that result is 10...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python has a flag -O that you can execute the interpreter with. The option
I have been developing the application which can manage a device using SMS commands;
I wonder if I can execute some programs for different cmd's using .bat file.
what is that and how I can execute it in my app? Maybe some
I require is to have a single stored procedure which can execute and show
Is there a c++(preferably MFC) database object that can execute multiple SQL statements(as in
I'm using ASP.NET MVC3 with razor engine.I want to apply css class on body
I'm trying to execute two events using the same class in jquery... having one
I have this query, that I execute a lot of times. Can you please
We can execute a shell command in vi. For example, typing in :!ls we

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.