public class StdMessage { public virtual Uri Type { get { return new Uri("http://Original.uri/bla"); } } } [TestMethod] [VerifyMocks] public void TypeMockTest() { StdMessage msg = new StdMessage(); Uri uriRet = new Uri("http://mocked.uri/bla"); using (RecordExpectations recorder = RecorderManager.StartRecording()) { // CAUTION: ALL calls here are mocked!!! Uri dummy = msg.Type; recorder.Return(uriRet); } Uri value = msg.Type; }
Test method UnitTests.TypeMock.TypeMockTest threw exception: TypeMock.TypeMockException: *** Cannot return a value for StdMessage.get_Type() because no value was set. use recorder.Return(). *** Note: Cannot mock types from mscorlib assembly..