chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
We were using 3.6.0. Upgraded to 3.7.1, now this test fails:

using (RecordExpectations recorder = RecorderManager.StartRecording())
{
// mock the things that require a valid connection string
SqlBackingStore sMock = new SqlBackingStore(null);
recorder.CallOriginal();
SqlDependency.Start(null);
sMock.SetUpChangeNotification();
}

I get the error below from TM, which faults the last line. The method SetupChangeNotification() return void. What is the problem here?

*** Mocked return value of SqlBackingStore.SetUpChangeNotification() is unknown, use recorder.Return().
*** Note: Cannot mock types from mscorlib assembly.
TypeMock.TypeMockException
Message:
*** Mocked return value of SqlBackingStore.SetUpChangeNotification() is unknown, use recorder.Return().
*** Note: Cannot mock types from mscorlib assembly.
Source: TypeMock
StackTrace:
at TypeMock.RecordExpectations.Dispose()
asked by rileytaylor (3.2k points)

2 Answers

0 votes
This is a defect that you found - thanks.
We have a problem with the error message.
It should be
*** Mocked return value of SqlDependency.Start() is unknown, use recorder.Return().

The actual message comes from one of the Breaking Changes in Version 3.7
We used to allow mocking types that returned ValueTypes without setting a value, TypeMock would then return the default result (0,false, ...)
This was a defect and now we fixed it.
So now you have to return a real value.
answered by scott (32k points)
0 votes
that works. Thanks
answered by rileytaylor (3.2k points)
...