I have just crafted the following test using Rhino mocks. Does my test look valid and make sense to those more experienced with mocking?
I am a a little confused that I haven't had to use the DynamicMock() or StrictMock() methods to create a seemingly valid test.
This test tests that the Add method was invoked on the supplied ICachingStrategy with the supplied parameters.
object o = new object();
DateTime d = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day + 1, 0, 0, 0);
CacheStorageStyle s = CacheStorageStyle.Unmodified;
string f = "test";
//arrange
var stubStrategy = MockRepository.GenerateStub<ICachingStrategy>();
var stubEncoder = MockRepository.GenerateStub<ICacheItemEncoder>();
stubStrategy.Stub(x => x.Add(o,d,s,f)).Return("test:key");
stubEncoder.Stub(x => x.Encode(o,s)).Return(o);
_mocks.ReplayAll();
//act
ICache c = new Cache(stubStrategy, stubEncoder);
c.Add(o, d, s, f);
//assert
stubStrategy.AssertWasCalled(x => x.Add(o,d,s,f));