I'm not sure... perhaps something in how the classes are defined. Here
is a test that passes for me...

 public class Presenter
        {
            private Controller Controller;

            public Presenter(Controller controller)
            {
                Controller = controller;
            }

            public void DoSomething()
            {
                Controller.Navigate("NestedView",
Controller.DataDocument);
            }
        }

        public class DataDocument
        {
        }

        public class Controller
        {
            public virtual DataDocument DataDocument { get; set; }

            public virtual void Navigate(string view, DataDocument
document)
            {

            }
        }

        [Test]
        public void ShouldNavigate()
        {
            var mockRepository = new MockRepository();
            var dataDocument = new DataDocument();
            var mockController = mockRepository.PartialMock<Controller>
();
            var presenter = new Presenter(mockController);

            mockRepository.Record();

            Expect.Call(mockController.DataDocument).Return
(dataDocument);
            LastCall.Repeat.Once();
            mockController.Navigate("NestedView", dataDocument);
            LastCall.Repeat.Once();

            mockRepository.ReplayAll();

            presenter.DoSomething();

            mockRepository.VerifyAll();
        }



On Aug 19, 10:56 pm, TheMightyKumquat <[email protected]> wrote:
> I have a method that looks like this in a Presenter class.
>
>         Public Sub DoSomething()
>
>             ' navigate to the nested view
>             ' use the data entered so far (if needed)
>             Controller.Navigate("NestedView", Controller.DataDocument)
>
>         End Sub
>
> The Controller object in the code is a mocked object in my test.
>
> Looking at this, it seemed simple to set the expectations for the
> test.
>
>      Dim dataDoc as new DataDocument()
>      ' Mock the property Get accessor
>      Rhino.Mocks.Expect.Call(mockController.DataDocument).Return
> (dataDoc)
>      LastCall.Repeat.Once()
>      ' Mock the Controller void method call
>      mockController.Navigate("NestedView", dataDoc)
>      LastCall.Repeat.Once()
>
> However, I was surprised to see that the test fails when the
> expectation for the Navigate method is included.
>
> Test method DoSomething_Test threw exception:
> Rhino.Mocks.Exceptions.ExpectationViolationException:
> IControllerBase.Navigate("TabWizard_NestedView", DataDocument);
> Expected #1, Actual #0..
>
> Take the Navigate void method call expectation out, and the test
> passes.
>
> Does anyone know why?

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