Using (mocks.Playback) will get you into replay mode

On 11/16/09, Tim Barcz <[email protected]> wrote:
> Haven't compile checked it it appears from first glance that you never
> get into replay mode.  You need to get into replay mode (since you're
> doing record/replay) for your return values to work.
>
> Hope that helps. Let me know.
>
> Tim
>
>
>
> On 11/16/09, devghost <[email protected]> wrote:
>>
>>
>> Hi,
>>
>> I'm fairly new to mocking with Rhino Mocks so bare with me :o)
>>
>> I got a test where I have stubbed my domain and want a method's
>> ByRef parameter to return a specific value, but no matter what I try
>> it never returns anything. This is what the test looks like.
>>
>>
>> <TestFixture()> _
>> Public Class When_typing_a_search_string_shorter_than_two_characters2
>>     Inherits ContextSpecification
>>
>>     Private mocks As MockRepository
>>     Private view As IObjectSelectionView
>>     Private domain As ObjectSelectionDomain
>>
>>     Private searchString As String
>>
>>     Protected Overrides Sub Context()
>>         mocks = New MockRepository()
>>
>>         view = mocks.DynamicMock(Of IObjectSelectionView)()
>>         domain = mocks.Stub(Of ObjectSelectionDomain)()
>>     End Sub
>>
>>
>>     Protected Overrides Sub Because()
>>         searchString = "S"
>>     End Sub
>>
>>
>>     <Test()> _
>>     Public Sub It_should_return_a_validationresult_errormessage()
>>         Dim validationResult = New ValidationResult("Search String Too
>> Short!")
>>
>>         Using mocks.Record()
>>             domain.GetObjects(Nothing, Nothing)
>>             LastCall.Return(New List(Of ObjectDto)).OutRef
>> (validationResult)
>>
>>             view.ErrorMessages = validationResult.ErrorMessages
>>         End Using
>>
>>         Dim presenter As ObjectSelectionPresenter = New
>> ObjectSelectionPresenter(view, domain)
>>         presenter.GetObjects()
>>
>>         mocks.VerifyAll()
>>     End Sub
>> End Class
>>
>> In the call to "domain.GetObjects(?,?)" I want the OutRef to be the
>> validationResult
>> containing the given error message "Search String Too Short". But It
>> always returns
>> a ValidationResult without an error message.
>>
>> Am I doing something obviously wrong here?
>>
>>
>> Thanks!
>>
>> >>
>>
>
> --
> Sent from my mobile device
>
> Tim Barcz
> Microsoft C# MVP
> Microsoft ASPInsider
> http://timbarcz.devlicio.us
> http://www.twitter.com/timbarcz
>

-- 
Sent from my mobile device

Tim Barcz
Microsoft C# MVP
Microsoft ASPInsider
http://timbarcz.devlicio.us
http://www.twitter.com/timbarcz

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to