Rhino Mocks Playback Syntax

Help, can someone help and explain the purpose of the Rhino Mocks recording area?

I assumed that the expectation set within the scope would only be checked, but it seems that as soon as you create the mockup of the object, Rhino Mocks is in recording mode, so I'm not sure about the purpose of the recording area now.

Here is an example that I have:

    private static void SomeTest()
    {
        MockRepository mockRepository = new MockRepository();
        ISomeInterface test = mockRepository.StrictMock<ISomeInterface>();

        test.Bar();

        using (mockRepository.Record())
        {
            Expect.Call<string>(test.GetFoo()).Return("Hello");
        }

        using (mockRepository.Playback()) 
        {
           test.GetFoo();
        }
    }

    public interface ISomeInterface
    {
        string GetFoo();
        void Bar();
    }

This test will fail because it is expected to call Bar . Is it because I created StrictMock and not Dynamic?

+3
source share
1 answer

This test will fail because there is no expected call to Bar (), but it has been called.

, , , . DynamicMock, , , . DynamicMocks , , StrictMocks , , .

Record/Replay, , MockRepository. StrictMock, , , , , .

+5

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


All Articles