Language: C#
NMock -> RhinoMocks
/************************************************************/ /* Set expectations for a method to be called only once */ /************************************************************/ // NMock: Expect.Once.On(mockLookupList).Method("Clear"); // Rhino Mocks mockLookupList.Expect(x => x.Clear()).Repeat.Once(); /************************************************************/ /* Set expectations for a method call with return value */ /************************************************************/ // NMock: // Check Expect.Once.On(mockLookupList).Method("GetLookupCollection").Return(mockLookupCollection); // Rhino Mocks: mockLookupList.Expect(x => x.GetLookupCollection()) .Return(mockLookupCollection) .Repeat.Once(); /************************************************************/ /* Set expectations for a method call with parameters */ /************************************************************/ // NMock: Expect.Once.On(mockLookupList).Method("Add").With(lookupDTO); // Rhino Mocks mockLookupLIst.Expect(x => x.Add(lookupDTO)).Repeat.Once(); /***********************************************************************/ /* Set expectations that a method called, we don't care how many times */ /***********************************************************************/ // NMock: Stub.On(mockLookupList).Method("Clear"); // Rhino Mocks: mockLookupList.Stub(x => x.Clear()); // check /***********************************************************************/ /* Dynamic mocks */ /***********************************************************************/ // NMock: DynamicMock mockUser = new NMock.DynamicMock(typeof(IUserInfo)); // Rhino Mocks: MockRepository mocks = new MockRepository(); IUserInfo mockuser = mocks.DynamicMock<IUserInfo>(); /***********************************************************************/ /* SetupResult */ /* tell the data mock to return sources when it gets called with Retrieve(). */ /***********************************************************************/ IList<Source> sources = new List<Source>() { new Source("x"), new Source("y"), new Source("z") }; // NMock: _Data.SetupResult("Retrieve", sources); // Rhino Mocks: SetupResult.For(_Data.Retrieve()).Return(sources);
Tags:
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

