Testing Partial Mock Methods

77 views
Skip to first unread message

Павел Лужецкий

unread,
Oct 3, 2012, 10:32:59 AM10/3/12
to rhino...@googlegroups.com
Hello all!

I have a trouble in using PartialMock for my tests.
When test comes to:
Expect.Call(cameraWorkflowService.IsModelExist(0)).IgnoreArguments().Return(true);

My test crushes coz class is not properly initialized and it calls original cameraWorkflowService.IsModelExist method not a fake one.

Is there any way to block default method implementation from executing?

My test code:
            var camRep = MockRepository.GenerateMock<ICamerasRepository>();
            var modelRep = MockRepository.GenerateMock<ICameraModelsRepository>();
            var adrrRep = MockRepository.GenerateMock<IAddressesRepository>();

            var camera = MockRepository.GenerateStub<ICamera>();
            var mocks = new MockRepository();
            var cameraWorkflowService = mocks.PartialMock<CameraWorkflowService>(camRep, adrrRep, modelRep);            
            Expect.Call(cameraWorkflowService.IsModelExist(0)).IgnoreArguments().Return(true);
            cameraWorkflowService.Replay();

            cameraWorkflowService.CheckBaseData(camera);    

Thanx!

Patrick Steele

unread,
Oct 3, 2012, 1:18:49 PM10/3/12
to rhino...@googlegroups.com
Is the method IsModeExist() virtual?

---
Patrick Steele
http://weblogs.asp.net/psteele
> --
> You received this message because you are subscribed to the Google Groups
> "Rhino.Mocks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rhinomocks/-/Vjp2C5ThoxMJ.
> To post to this group, send email to rhino...@googlegroups.com.
> To unsubscribe from this group, send email to
> rhinomocks+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rhinomocks?hl=en.
Reply all
Reply to author
Forward
0 new messages