Я пытаюсь использовать синтаксис AAA в Rhino Mocks с VB.Net, чтобы проверить, что метод был вызван только один раз. Я могу' Кажется, я правильно понял. В этом коде, если репозиторий вызывается дважды, он ничего не возвращает при втором вызове, и тест проходит. Я ожидал, что при вызове VerifyAllExpectations тест завершится неудачно.
<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