I do not see a call to
Rhino.Mocks.Expect.Call(mockController.Entity).Return(fakeEntity)

since mockController is a mock object, setting
mockController.EntityDocument will not set the mockController.Entity

On Mon, Aug 10, 2009 at 8:15 PM, TheMightyKumquat<[email protected]> wrote:
>
> Can anyone explain the difference between these two tests?
>
> If I test the method PersistTab1 with the first Test below, it passes.
>
>    Public Function PersistTab1(ByVal validate As Boolean)
>        Dim entity = View.Entity
>
>        Controller.EntityDocument = entity
>
>        Return False
>    End Function
>
> With this test, it passes.
>      <TestMethod()> Public Sub PersistTab1()
>
>        Dim mocks As New MockRepository()
>        Dim mockController As IController = mocks.DynamicMock(Of
> IController)()
>        Dim mockView As IView = mocks.DynamicMock(Of IView)()
>
>        Dim fakeEntity As New EntityDocument()
>        fakeEntity.SampleString1 = "xxx"
>
>        ' Expectations: View.Entity gets accessed to set entity var
>        Rhino.Mocks.Expect.Call(mockView.Entity).Return(fakeEntity)
>
>        ' controller's Entity prop gets set
>        mockController.EntityDocument = fakeEntity
>
>        mocks.ReplayAll()
>
>        Dim target As Form1 = New Form1()
>        target.View = mockView
>        target.Controller = mockController
>
>        Dim result As Boolean = target.PersistTab1(False)
>
>        Assert.IsFalse(result)
>
>        mocks.VerifyAll()
>    End Sub
>
> But if I change the code being tested to access an inner property of
> the object the code uses - the Entity document, then my test fails.
> The test code throws an Null Reference exceptioin where I set the
> expectation for the Controller's Entity property being set. Why?
>
>    Public Function PersistTab1(ByVal validate As Boolean)
>
>        Dim entity = View.Entity
>
>        Controller.Entity.SampleString1 = entity.SampleString1
>
>        Return False
>    End Function
>
>
>
>
>
> I have a feeling that this is a sign that I'm not understanding mock
> objects at some basic level.
>
> >
>

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