Indeed, that was it. Now it works as it should. Many thanks to you both you saved my day (been spending a couple of hours to get this to work with no luck).
Thanks! On 16 Nov, 14:59, Alex McMahon <[email protected]> wrote: > I'm probably missing something, but don't you need: > LastCall.*IgnoreArguments()*.Return(New List(Of ObjectDto)).OutRef > (validationResult) > > is the call to domain.GetObjects in your presenter returning null? or the > empty list you're specifying? > > 2009/11/16 devghost <[email protected]> > > > > > > > Thanks Tim for your reply, I have corrected the test method to use the > > Playback method. > > > <Test()> _ > > Public Sub It_should_return_a_validationresult_errormessage() > > Using mocks.Record() > > Dim validationResult = New ValidationResult("Search String > > Too Short!") > > > domain.GetObjects(Nothing, Nothing) > > LastCall.Return(New List(Of ObjectDto)).OutRef > > (validationResult) > > > view.ErrorMessages = validationResult.ErrorMessages > > LastCall.IgnoreArguments() > > End Using > > > Using mocks.Playback() > > Dim presenter As ObjectSelectionPresenter = New > > ObjectSelectionPresenter(view, domain) > > presenter.GetObjects() > > End Using > > End Sub > > > However, the problem still remains. When the presenter.GetObjects() in > > turn call the domain.GetObjects(searchString, ByRef validationResult) > > the ByRef (out) validationResult parameter does not contain the error > > message that I wanted it to specified in the Record part. > > > Kind Regards, > > Robert > > > On 16 Nov, 13:27, Tim Barcz <[email protected]> wrote: > > > 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 ASPInsiderhttp://timbarcz.devlicio.ushttp:// > >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 -~----------~----~----~----~------~----~------~--~---
