From memory I think the main difference is that GenerateStub<T>
returns an object with normal property behaviour.
For example (psuedo-code only, haven't tested):
var stub = MockRepository.GenerateStub<ISomething>();
stub.MyProperty = 2;
Assert.AreEqual(stub.MyProperty, 2);
If you try the same with a mock then MyProperty would return 0 (or
null for reference type). If you want the property of a mock to return
a specific value you have to stub it (confusing, right? :-)).
var mock = MockRepository.GenerateMock<ISomething>();
mock.MyProperty = 2;
Assert.AreEqual(mock.MyProperty, 0);
mock.Stub(x => x.MyProperty).Return(2);
Assert.AreEqual(mock.MyProperty, 2);
I think that's right, but you should probably run it and make sure I
have a vague idea of what I'm talking about. ;)
My approach is to use GenerateStub<T> everywhere. I don't remember the
last time I needed/wanted the GenerateMock<T> behaviour (at least not
when using AAA style testing).
Hope this helps.
Regards,
David