Is there any difference between SetupResult and Stub in RhinoMocks?

Is there, if any?

    var storage = mocks.DynamicMock<IStorage>();

...

    SetupResult.For(storage.GetCustomers())
        .Return(new Collection<Customer> { cust1, cust2 });

            // and

    storage.Stub(x => x.Customers)
        .Return(new Collection<Customer> { cust1, cust2 });
+3
source share
1 answer

EDIT: I have not seen an extension method before Stub, just a method in the repository.

I suspect that the main difference is that you can call Stubwhen the layout is in any mode (playback or recording). It will temporarily return it to recording mode, record the action, and then return to playback if it starts playback in playback mode.

It also allows you to cut out multiple actions in a single lambda expression if you only need one of the actions (the last) to return the result.

+3
source

Source: https://habr.com/ru/post/1708621/


All Articles