unit testing - Rhino Mocks: How to verify a method was called exactly once using vb.net and AAA syntax -


I am trying to use AAA syntax with VB.Net in Rhino Mox so that it can be verified that one The method has been called only one time. I do not think this is right. With this code, if the repository is called twice, then it does not do anything on the second call, and the exam is passed. VerifyAllExpectations were called, so I was hoping to fail in the exam.

  & lt; TestMethod () & gt; Public Sub GetDataCallsRepositoryOneTime () Dima Repository IdataRepository = MockRepository.GenerateMock (IDataRepository's) () Dim cache repository as new cache dataType repository Dim results1 IEnumerable (DataItem's) Dim result 2 IEnumerable form In (DataItem's) 'Confirm that the base repository was once asked for the repository only once for its data. (Function (x) x.getdata (1)). Return (GetSampleData). Repetition Once () results1 = cacheRepository.GetData (1) results2 = cacheRepository.GetData (1) SDR .VerifyAllExpectations () ending sub  

If you are using VS2010, you can use

how to use AAA syntax w / rhino mock (using C #), but your question You can quickly do the following to answer:

The first class you want to verify some interactive behavior (super simple but this works)

  Public Sector C Lass1 Public Overdrive Sub Happy () and all People Overridwy all doitie () Happy () Happy (and end) end of class class  

The test method used to use the next AAA + VB is called 2x

   

Comments