Can Rhino Soak deeper / nested members directly?

Is it possible to scoff at calling a stub member / layout without defining it as a stub, and also set the return value as all separate verbose lines?

Example:

[TestMethod] public void AssignedPermissions_AssociateExists_ReturnsEdit_Rhino() { //Arrange var fakeConfiguration = MockRepository.GenerateStub<IDomainControllerConfiguration>(); var fakeAssociateRepository = MockRepository.GenerateStub<IAssociateRepository>(); fakeConfiguration.Stub(x => x.AssociateRepository).Return(fakeAssociateRepository); fakeAssociateRepository.Stub(x=>x.GetAssociatesByRole(null,false,null)).IgnoreArguments() .Return(new IAssociate[]{MockRepository.GenerateStub<IAssociate>()}); var domain = new DomainController(fakeConfiguration); const AssignedPermission expected = AssignedPermission.Edit; //Act AssignedPermission actual = domain.AssignedPermissions(); //Assert Assert.AreEqual(expected, actual); } 

Are all these temporary variables necessary only to exclude nested method calls?

+6
unit-testing rhino-mocks
source share
1 answer

I never used functionality, so I'm not 100% sure that this will work, but theoretically Rhino mocks supports a " recursive mockery ", which should allow you to at least cut fakeAssociateRepository by doing something like this:

 var fakeConfiguration = MockRepository.GenerateStub<IDomainControllerConfiguration>(); fakeConfiguration.Stub(x => x.AssociateRepository.GetAssociatesByRole(null,false,null)) .IgnoreArguments() .Return(new IAssociate[]{MockRepository.GenerateStub<IAssociate>()}); var domain = new DomainController(fakeConfiguration); 

(note: code not verified or even compiled)

+3
source share

All Articles