Hi,
Back again, still tinkering with Rhino and VB.NET 2010. I am having
some progress but I have hit another impasse and I hope I am not being
blind or stupid again, but.
I am testing this class:

Public Class CalendarsController

    Private _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
       .....
        AddHandler _view.Save, AddressOf OnSaveCalendar
    End Sub

    Private Sub OnCreateNewCalendar(ByVal sender As Object, ByVal e As
EventArgs)
        Dim c As Calendar = _model.CreateNewCalendar(CType(sender,
ICalendarsView).CalendarName)
    End Sub
......
    Private Sub OnSaveCalendar(ByVal sender As Object, ByVal e As
EventArgs)
        Dim v As ICalendarsView = CType(sender, ICalendarsView)
        Dim c As New Calendar(v.CalendarName, v.WeekDayNames,
v.MonthNames, v.MonthLengths, v.StartDayNameForYear)
        _model.SaveCalendar(c)

    End Sub

End Class

I have a test:

<TestMethod()> Public Sub TestCreateNewCalendarFromView()
        Dim view As ICalendarsView
        view = MockRepository.GenerateStub(Of ICalendarsView)()
        Dim model As ICalendarEngine
        model = MockRepository.GenerateMock(Of ICalendarEngine)()
        Dim c As New Calendar
        view.CalendarName = "Dale Reckoning"
        model.Stub(Function(e)
e.CreateNewCalendar(view.CalendarName)).IgnoreArguments.Return(c)
        Dim controller As New CalendarsController(view, model)


        view.GetEventRaiser(Sub(x) AddHandler x.CreateNewCalendar,
Nothing).Raise(view, New EventArgs)
        model.AssertWasCalled(Function(e)
e.CreateNewCalendar(view.CalendarName))

    End Sub

It works pretty much as expected.

Now this test;

  <TestMethod()>
    Public Sub TestEventSaveIsHandledAAAWay()
        Dim view As ICalendarsView
        Dim model As ICalendarEngine
        view = MockRepository.GenerateStub(Of ICalendarsView)()
        model = MockRepository.GenerateMock(Of ICalendarEngine)()

        model.Stub(Sub(e) e.SaveCalendar(Nothing)).IgnoreArguments()
        Dim controller As New CalendarsController(view, model)
        view.GetEventRaiser(Sub(x) AddHandler x.Save,
Nothing).Raise(view, New EventArgs)
        model.AssertWasCalled(Sub(e) e.SaveCalendar(New Calendar))

    End Sub
Does not work. It fails and tells that that it expected #1 and actual
of #0
Now, the only difference I can see is that in the latter test I am
setting the expectation call on a Sub and in hte other I am setting it
on a Function.

I am in the process of downloading the final release of VS2010 so I
have only been working on the release canditate so far.

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