The role of the listener and the mutator can sometimes be combined in one class (for example, in the adapter), but both roles should not be tested together.
In one test, you simply confirm that your listening class responds to the PropertyChanged event as it was designed. It doesn't matter to you what the property changed in this test:
[Test] public void Updates_Caption_when_Bar_PropertyChanged() { var foo = MockRepository.GenerateStub<IFoo>(); foo.Bar = "sometestvalue1"; var underTest = new UnderTest(foo);
In another test, you verify that your class plays the role of a mutator in accordance with its construction:
[Test] public void Reset_clears_Foo_Bar() { var foo = MockRepository.GenerateStub<IFoo>(); foo.Bar = "some string which is not null"; var underTest = new UnderTest(foo); underTest.Reset();
Thus, you never need to introduce real logic into your mock objects, as you are trying to do. This requires that you design your classes for validation; itβs hard to add such tests to existing classes. Therefore, the practice is test driven development .
source share