partial-mocks

Expectations on Partial Mock - NullReference Exception

I've a problem with partial mocking using Rhino Mocks: var authentication = (FormsAuthenticationService)_mocks.PartialMock( typeof(FormsAuthenticationService)); Expect.Call( delegate{ authentication.SetAuthCookie(null, null); }).IgnoreArguments(); ..and I get NullReferenceException on "Expect." line.. I will just add that FormsAuth...

Why does my partial mock have all virtual methods mocked, even if no expectations are set?

I have a user control which does some validation in the ValidateChildren method which I would like to test. I have created a partial mock of the user control, but although I am not setting any expectations on the ValidateChildren method, I am simply calling it, it is simply skipped and the code inside the method never executes. To try ...

Rhino Mocks mock inherited interface

Hi, i have a class e.g. DerivedClass that inherits from a base class e.g. BaseClass. BaseClass implements an interface called IBaseClass. IBaseClass has 1 property called TestProperty which is an integer auto property. I PartialMultiMock DerivedClass like so: derivedClassMock = repository.PartialMultiMock<DerivedClass>(typeof(IBaseIn...

Prefer Dependency-Injection over Partial Mocking?

I know this SO question, but it deals with the subject in more general terms. Should I prefer using partial Mocks over Dependency Injection? My question is based on the following quote from OCMock: id aMock = [OCMockObject partialMockForObject:anObject] Creates a mock object that can be used in the same way as anObject. When a ...

Partial Mocking As Code Smell?

Why is there so much hating going on about 'partial mocking' and the code that requires it? Here's an (theoretical) example implementation: public ComplexResult1 operationA(Stimulus a) { { ... result = ...; } auditTheChange(a); } public ComplexResult2 operationB(Stimulus b) { { ... result...