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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:22:18+00:00 2026-05-30T20:22:18+00:00

I have a read-only dictionary on a dependency that I’d like to be able

  • 0

I have a read-only dictionary on a dependency that I’d like to be able to stub with return values, and check that assignments to it have happened.

I was hoping that Rhino.Mocks would create an empty dictionary for me by default, but unfortunately it doesn’t. Since it is read-only, I can’t create a new dictionary and assign it to that property.

I was hoping to be able to stub it instead. From what I understand, the C# syntax for this would looking something like this:

m.Stub(x => x.myProperty).Return("abc");

So I was hoping that this would work for VB:

m.Stub(sub(x) x.myProperty).Return("abc");

But it doesn’t (compiler error). Any ideas on how to accomplish this? I’m open to the Expect/Verify syntax if it can accomplish this…

  • 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-30T20:22:20+00:00Added an answer on May 30, 2026 at 8:22 pm

    Using Function will do the trick:

    m.Stub(Function(x) x.myProperty).Return("abc")
    

    If you want to verify whether myProperty got called you could use Expect instead of Stub:

    m.Expect(Function(x) x.myProperty).Return("abc")
    
    // Some code here
    
    m.VerifyAllExpectations()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a read only combo-box with 5 values in, when the user selects
Now that I have a read-only application working, I am working on the insert
I have a class that defines a read-only property that effectively exposes a private
I have an sqlite database, and I would like to keep it read-only without
I would like to have a manager process sharing graphs via shared memory, read-only
I have some questione about NSMutableDictionary. I read that they are only a wrapper
Let's say that I have a website where I'd like users to be able
I have read that ConcurrentDictionary only locks when writing, so the reads are lock
Many library classes in AS3 have read only properties. Is it possible to create
I have a web page with a read-only text box which shows some HTML

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.