/ Published in: C#
Note that the interface member is mockVar.Object mockVar won't cast to your interface.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public Sandbox GetMockedSandbox(string helloPrefix, string ackWord, int factor) { mockFactory.Expect(fac => fac.GetWorker(It.IsAny<int>())).Returns(mockWorker.Object); mockWorker.Expect(ds => ds.Hello(It.IsAny<string>())).Returns((string s) => helloPrefix + s); mockWorker.Expect(ds => ds.Ping()).Returns(ackWord); mockWorker.Expect(ds => ds.MultiplyYourNumber(It.IsAny<int>())).Returns((int i) => i * factor); retVal.ImplementationFactory = mockFactory.Object; return retVal; }
URL: http://code.google.com/p/moq/wiki/QuickStart