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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:53:38+00:00 2026-05-16T08:53:38+00:00

I was having problems with a second call on a mock in my test

  • 0

I was having problems with a second call on a mock in my test run, so I moved the double calls into the test method. I have this:

RefBundle mockIRefBundle = mocks.StrictMock<IRefBundle>();

Expect.Call(mockIRefBundle.MaxTrackItems).Return( 6 ).Repeat.Any();

int q = mockIRefBundle.MaxTrackItems;
int z = mockIRefBundle.MaxTrackItems;

It fails when I make the second call to set “z” with an exception that implies the method was already called:

Error message:

System.InvalidOperationException: Previous method 
'IRefBundle.get_MaxTrackItems();
'requires a return value or an exception to throw..

and Stack

Rhino.Mocks.Impl.RecordMockState.AssertPreviousMethodIsClose()
Rhino.Mocks.Impl.RecordMockState.MethodCall(IInvocation invocation, 
...

The second call doesn’t seem to honor the Repeat.Any()

What am I missing?

  • 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-16T08:53:38+00:00Added an answer on May 16, 2026 at 8:53 am

    Either you have to use the new syntax:

    RefBundle mockIRefBundle = MockRepository.GenerateMock<IRefBundle>();
    
    mockIRefBundle.Expect(X => x.MaxTrackItems).Return(6).Repeat.Any();
    
    int q = mockIRefBundle.MaxTrackItems;
    int z = mockIRefBundle.MaxTrackItems;
    

    or alternatively you need to call ReplayAll() before you start using your mocks:

    RefBundle mockIRefBundle = MockRepository.GenerateMock<IRefBundle>();
    
    mockIRefBundle.Expect(X => x.MaxTrackItems).Return(6).Repeat.Any();
    
    mocks.ReplayAll();
    int q = mockIRefBundle.MaxTrackItems;
    int z = mockIRefBundle.MaxTrackItems;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems with this call: m_baseMap.find(baseName)->second->AddVehicale(vehicaleToAdd); There's a red line under m_baseMap ,
I'm having problems with counting method calls with Mockito. Problem is that the method
Im having problems with a method in a class file: public static function getPageLeft($pid)
I am having problems calling a URL from PHP code. I need to call
For some reason I've having problems reading this session variable within an ajax document,
I'm a few days into learning Clojure and are having some teething problems, so
I'm having problems with mysqli_query . I have methods set up in a singleton
I've recently having problems with custm CALLBACK's function pointers, and that boiled down into
I'm having a big issue with a static HTTPS connection method. Every second request
The problem I'm having is that the first URL works and the second one

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.