Not sure if it helps for this particular case, but I wrote an intro to AAA
with Rhino Mocks a while back, although you'll have to translate it from C#:

http://www.davesquared.net/2008/10/very-basics-of-aaa-with-rhino-mocks-35.html

<http://www.davesquared.net/2008/10/very-basics-of-aaa-with-rhino-mocks-35.html>Oh,
you asked for a "good" resource. Never mind. ;)


On Wed, Apr 14, 2010 at 10:03 PM, Joseph Dineen <[email protected]>wrote:

> Thanks,
> It apprears to have been simple blindness on my part.
>
> So can anyone point me at a good resource to recast it in the newer
> AAA syntax?
>
>
>
> On Apr 14, 12:45 pm, bill richards <[email protected]>
> wrote:
> > Further to this ....
> >
> > this is the reasn for my reluctance to use StrictMock : the use of a
> > StrictMock implies your internal knowledge of the item being mocked,
> > you need to know what the internal implications are for making a call.
> > To me, this is at far too granular a level.
> >
> > On Apr 14, 12:42 pm, bill richards <[email protected]>
> > wrote:
> >
> > > In that line of code you have said:
> >
> > > I expect the member CreateNewCalendar to be called on model using the
> > > value view.CalendarName as a parameter.
> > > I expect it to be called at least once and it will return c.
> >
> > > Nowhere have you stated that you expect model.GetCalendar to be
> > > called.
> >
> > > On Apr 14, 12:08 pm, Joseph Dineen <[email protected]> wrote:
> >
> > > > But I thought that the Line in my test
> >
> > > >
> Rhino.Mocks.Expect.Call(model.CreateNewCalendar(view.CalendarName)).Repeat.­­AtLeastOnce.Return(c)
> >
> > > > Sets up such an expectation?
> >
> > > > If it does not then how does one set up the expectation?
> >
> > > > On Apr 14, 11:49 am, bill richards <[email protected]>
> > > > wrote:
> >
> > > > > The point that Tim is making is that, ANY call that is made on your
> > > > > StrictMock, for which you HAVE NOT set an expectation for, will
> cause
> > > > > the test to fail.
> >
> > > > > Whe you use a StrictMock, you have to set an expectation for EVERY
> > > > > call made on that object. So it is completely expeted that a call
> to
> > > > > model.GetCalendar will throw an expectation excepton, since you
> have
> > > > > not set up such an expectation.
> >
> > > > > On Apr 14, 11:07 am, Joseph Dineen <[email protected]>
> wrote:
> >
> > > > > > Well I have tried it using DynamicMock instead of StrictMock and
> it
> > > > > > made no difference.
> > > > > > Besides, the line
> >
> > > > > > > >
> Rhino.Mocks.Expect.Call(model.CreateNewCalendar(view.CalendarName)).Repeat.­­­AtLeastOnce.Return(c)
> >
> > > > > > Should create the expectation and I know the event is raised
> because I
> > > > > > can see the call in the event in the debugger.
> > > > > > The problem arises when the cal is made to the model.GetCalendar
> > > > > > method. There the expectation exception gets raised.
> > > > > > I have akso tried adding IgnoreArguments to no avial.
> > > > > > I am sure I am missing something but I do not know what.
> >
> > > > > > On Apr 13, 8:39 pm, Tim Barcz <[email protected]> wrote:
> >
> > > > > > > It appears you are using strict mocks...which means any call
> not "expected"
> > > > > > > will cause the test to fail.
> >
> > > > > > > On Tue, Apr 13, 2010 at 11:40 AM, Joseph Dineen <
> [email protected]>wrote:
> >
> > > > > > > > Hi, I am new to Rhino Mocks and I have tried to post this
> message
> > > > > > > > before but it does not seem to have appeared on the
> messageboard nor
> > > > > > > > did I get any indication that the moderators have seen the
> message.
> > > > > > > > While i have been using Unit Testing and TDD for a while I
> have not
> > > > > > > > gotten into mocking in any major way. I did use DotNetMock
> for a while
> > > > > > > > in a single project and I want to refactor parts of it using
> VB.NET
> > > > > > > > 2010 as a learning excersise but found that DotNetMock does
> not play
> > > > > > > > well with MSUnitTest and appears to be a dead project.
> > > > > > > > So I decided to learn Rhino Mocks after some research on the
> net.
> > > > > > > > To do this I decided to implement a view model comtoller
> application
> > > > > > > > and communicate from the view to the controller with events,
> call
> > > > > > > > stuff from the model in the event handlers on the controller
> and see
> > > > > > > > how it works out. I also decided to use the older Replay
> verify syntax
> > > > > > > > since I have mostly worked with 2005 and earlier and have not
> yet
> > > > > > > > looked at lambda functions. Also the only examples in vb I
> could find
> > > > > > > > used this systax and while I could see that the C# lambda
> stuff was
> > > > > > > > trying to do I have no idea of how to implement that code in
> vb.
> > > > > > > > So some code ( the application aim to generate fantasy
> calendars for
> > > > > > > > rpgs.)
> >
> > > > > > > > ''' <summary>
> > > > > > > > ''' This the view of the calendars
> > > > > > > > ''' </summary>
> > > > > > > > Public Interface ICalendarsView
> >
> > > > > > > >    'the events represent user actions that are addressed by
> the model
> > > > > > > >    Event CreateNewCalendar As EventHandler
> >
> > > > > > > >    Event Save As EventHandler
> >
> > > > > > > >    Event GetCalendarList As EventHandler
> >
> > > > > > > >    Event GetCalendar As EventHandler
> >
> > > > > > > >    Property CalendarName As String
> >
> > > > > > > >   ......
> >
> > > > > > > >    'these methods allow the controller to pass data to the
> view
> > > > > > > >    Sub ShowPreviewForYear(ByVal yearNumber As Integer)
> >
> > > > > > > >    Sub SetCalendar(ByVal c As Calendar)
> >
> > > > > > > >    Sub SetCalendarList(ByVal calList As List(Of Calendar))
> >
> > > > > > > > End Interface
> >
> > > > > > > > ''' <summary>
> > > > > > > > ''' the Model
> > > > > > > > ''' </summary>
> > > > > > > > ''' <remarks></remarks>
> > > > > > > > Public Interface ICalendarEngine
> >
> > > > > > > >    Function GetCalendars() As List(Of Calendar)
> >
> > > > > > > >    Function GetCalendar(ByVal name As String) As Calendar
> >
> > > > > > > >    Function CreateNewCalendar(ByVal name As String) As
> Calendar
> >
> > > > > > > >    Sub SaveCalendar(ByVal c As Calendar)
> >
> > > > > > > > End Interface
> >
> > > > > > > > The controller
> > > > > > > > '' <summary>
> > > > > > > > ''' Controller of the view
> > > > > > > > ''' </summary>
> > > > > > > > ''' <remarks>Instantiated and refers to the model and the
> view</
> > > > > > > > remarks>
> > > > > > > > Public Class CalendarsController
> >
> > > > > > > >    Private WithEvents _view As ICalendarsView
> > > > > > > >    Private _model As ICalendarEngine
> >
> > > > > > > >    Public Sub New(ByVal view As ICalendarsView, ByVal model
> As
> > > > > > > > ICalendarEngine)
> > > > > > > >        If IsNothing(view) Or IsNothing(model) Then
> > > > > > > >            Throw New ArgumentNullException("Passed parameters
> were
> > > > > > > > not instantiated")
> > > > > > > >        End If
> > > > > > > >        _view = view
> > > > > > > >        _model = model
> > > > > > > >        'Add the event handlers
> > > > > > > >        AddHandler _view.CreateNewCalendar, AddressOf
> > > > > > > > OnCreateNewCalendar
> >
> > > > > > > >    End Sub
> >
> > > > > > > >    Private Sub OnCreateNewCalendar(ByVal sender As Object,
> ByVal e As
> > > > > > > > EventArgs)
> > > > > > > >        Dim c As Calendar = _model.GetCalendar(CType(sender,
> > > > > > > > ICalendarsView).CalendarName)
> >
> > > > > > > >    End Sub
> >
> > > > > > > > The test
> >
> > > > > > > > Imports System.Text
> > > > > > > > Imports ArdoughterSoftware.FantasyCalendar
> > > > > > > > Imports Rhino.Mocks
> > > > > > > > Imports Rhino.Mocks.Interfaces
> >
> > > > > > > > <TestClass()>
> > > > > > > > Public Class TestCalendarsController
> >
> > > > > > > >    Private testContextInstance As TestContext
> >
> > > > > > > >    '''<summary>
> > > > > > > >    '''Gets or sets the test context which provides
> > > > > > > >    '''information about and functionality for the current
> test run.
> > > > > > > >    '''</summary>
> > > > > > > >    Public Property TestContext() As TestContext
> > > > > > > >        Get
> > > > > > > >            Return testContextInstance
> > > > > > > >        End Get
> > > > > > > >        Set(ByVal value As TestContext)
> > > > > > > >            testContextInstance = value
> > > > > > > >        End Set
> > > > > > > >    End Property
> >
> > > > > > > >    Private moMockery As MockRepository
> >
> > > > > > > >  ' Use TestInitialize to run code before running each test
> > > > > > > >    <TestInitialize()> Public Sub MyTestInitialize()
> > > > > > > >        moMockery = New MockRepository
> > > > > > > >    End Sub
> > > > > > > >    '
> > > > > > > >    ' Use TestCleanup to run code after each test has run
> > > > > > > >    <TestCleanup()> Public Sub MyTestCleanup()
> > > > > > > >        moMockery.VerifyAll()
> > > > > > > >    End Sub
> >
> > > > > > > >    Public Sub TestCreateNewCalendarEventIsRaisedTheOldWay()
> > > > > > > >        Dim e As New EventArgs
> > > > > > > >        Dim c As New Calendar
> > > > > > > >        Dim view As ICalendarsView
> > > > > > > >        view = moMockery.Stub(Of ICalendarsView)()
> > > > > > > >        Dim model As ICalendarEngine
> > > > > > > >        model = moMockery.StrictMock(Of ICalendarEngine)()
> > > > > > > >        Dim calendarName As String = "Dale Reckoning"
> > > > > > > >        view.CalendarName = calendarName
> > > > > > > >        AddHandler view.CreateNewCalendar, Nothing
> > > > > > > >        LastCall.Constraints(Constraints.Is.NotNull)
> >
> > > > > > > >        Dim CreateNewCalendarEventRaiser As IEventRaiser =
> > > > > > > > LastCall.GetEventRaiser()
> >
> > > > > > > >
> Rhino.Mocks.Expect.Call(model.CreateNewCalendar(view.CalendarName)).Repeat.­­­AtLeastOnce.Return(c)
> >
> > > > > > > >        moMockery.ReplayAll()
> >
> > > > > > > >        Dim controller = New CalendarsController(view, model)
> >
> > > > > > > >        CreateNewCalendarEventRaiser.Raise(CType(view,
> Object), e)
> > > > > > > >    End Sub
> >
> > > > > > > > End Class
> >
> > > > > > > > The Error message
> >
> > > > > > > > Test method
> >
> > > > > > > >
> TestCalendars.TestCalendarsController.TestCreateNewCalendarEventIsRaisedThe­­­OldWay
> > > > > > > > threw exception:
> > > > > > > > Rhino.Mocks.Exceptions.ExpectationViolationException:
> > > > > > > > ICalendarEngine.GetCalendar("Dale Reckoning"); Expected #0,
> Actual #1.
> > > > > > > > TestCleanup method
> TestCalendars.TestCalendarsController.MyTestCleanup
> > > > > > > > threw exception.
> Rhino.Mocks.Exceptions.ExpectationViolationException:
> > > > > > > > Rhino.Mocks.Exceptions.ExpectationViolationException:
> > > > > > > > ICalendarEngine.GetCalendar("Dale Reckoning"); Expected #0,
> Actual
> > > > > > > > #1..
> >
> > > > > > > > Now Googling that message, would indicate that the method and
> the
> > > > > > > > event raise are not getting the parameters they expect and
> that they
> > > > > > > > are expecting a particular instance of an object. Which I do
> not
> > > > > > > > understand as they are getting the same instance of the
> object. I have
> > > > > > > > tried placing
> >
> > ...
> >
> > read more »
>
> --
> 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]<rhinomocks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rhinomocks?hl=en.
>
>

-- 
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