NMock2 question
Date: 07/08/09
(C Sharp) Keywords: no keywords
Is there a way to change what a mock returns from its faked methods or properies after it has been initialised?
For instance if I am testing myContainer to see if it supports repeated attempts to Add the same Foo instance regardless of the value of the Foo's boolean Bar property I want to do something like
myMockery = new Mockery(); myFoo = myMockery.NewMock(); Stub.On(myFoo).GetProperty("Bar").Will(Return.Value(false)); myCollection.Add( myFoo ); Stub.On(myFoo).GetProperty("Bar").Will(Return.Value(true)); myCollection.Add( myFoo ); Assert something about myCollection
But it seems that once you use "Stub.On" any subsequent Stub.On the same object has no effect?
Source: http://csharp.livejournal.com/104068.html
|