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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:47:07+00:00 2026-05-17T15:47:07+00:00

I am trying to use the AAA syntax in Rhino Mocks with VB.Net to

  • 0

I am trying to use the AAA syntax in Rhino Mocks with VB.Net to validate that a method was called only one time. I can’t seem to get it right. With this code, if the repository is called twice, it returns nothing on the second call, and the test passes. I would have expected the test to fail when VerifyAllExpectations was called.

<TestMethod()>
Public Sub GetDataCallsRepositoryOneTime()
    Dim repository As IDataRepository = MockRepository.GenerateMock(Of IDataRepository)()
    Dim cacheRepository As New CachingDataRepository(repository)
    Dim results1 As IEnumerable(Of DataItem)
    Dim results2 As IEnumerable(Of DataItem)

    'verify that the base repository was asked for its data one time only
    repository.Expect(Function(x) x.GetData(1)).Return(GetSampleData).Repeat.Once()

    results1 = cacheRepository.GetData(1)
    results2 = cacheRepository.GetData(1)

    sdr.VerifyAllExpectations()
End Sub
  • 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-17T15:47:08+00:00Added an answer on May 17, 2026 at 3:47 pm

    If you are using VS2010 you get much improved lamba support (including a much better experience using Rhino Mocks with VB)

    I outline how to use AAA syntax w/ rhino mocks here (using c#) but to answer your question quickly you could do the following

    First the class you want to verify some interactive behavior (super simple but it works)

    Public Class Class1
        Public Overridable Sub Happy()
    
        End Sub
    
        Public Overridable Sub DoIt()
            Me.Happy()
            Me.Happy()
        End Sub
    End Class
    

    Next the test written using AAA + vb to prove the Happy method gets called 2x

    <TestClass()>
    Public Class UnitTest2
    
        <TestMethod()>
        Public Sub TestMethod1()
            Dim x = MockRepository.GeneratePartialMock(Of Class1)()
    
            x.DoIt()
    
            x.AssertWasCalled(Sub(y) y.Happy(), Sub(z) z.Repeat.Times(2))
        End Sub
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trying to use putExtra and getExtra with Bundle to share variables across activities: this
Trying to use autdoc extension of sphinx but its not working. i kept docs
I'm trying to use a SELECT statement and fetch all rows from a table
I'm trying to use distance_of_time_in_words (Rails 3) on a created_at column of an ActiveRecord
I'm trying to use the Edit Control within an Dialog. When I use this
I am trying to use the country detection by IP, an API from http://www.hostip.info/use.html
I'm trying to use Microsoft's Translator API in my Rails app. Unfortunately and mostly
I'm trying to use Scrapy to scrape the U.S. government regulations website (www.regulations.gov). It's
I'm trying to use cluttermm to create a borderless window (for example, something like
I am trying to use NHibernate to persist objects using Guids for their Ids

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.