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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I don't know, is it your bug or Microsoft, but I decided to start from you. Sorry :)
I have a strange error in VS 2012 only (in VS 2010 all works fine).
I need to mock the following thing:
using (RecordExpectations recorder = RecorderManager.StartRecording())
    recorder.ExpectAndReturn(System.Configuration.ConfigurationManager.AppSettings.Get(""), "0");

A get an exception on line with "recorder.ExpectAndReturn(...);":
Test method TestExample.UnitTests.UnitTest1.TestSumMethod threw exception:
*** Cannot use Return in this sequence, there must be a mocked statement first
Perhaps you are trying to mock a method from an unsupported mscorlib type. See supported types here:
Result StackTrace:
at TypeMock.RecordExpectations.b(String A_0)
at TypeMock.RecordExpectations.a(String A_0)
at TypeMock.RecordExpectations.Return(Object returnValue)
at TypeMock.RecordExpectations.ExpectAndReturn(Object mockedStatements, Object returnValue)
at TestExample.UnitTests.UnitTest1.TestSumMethod() in d:ProgiWork_TestTestExampleTestExample.UnitTestsUnitTest1.cs:line 15

The error appears only if a testsetting (testrunconfig) file is specified in Test->Test Settigns.
My OS is x64, so I check "X64" in Test->Test Settings->Default Processor Architecture.
I have created a small example: just one class with one method, one unit test project with one test and 3 lines. It works, if no testsettings files are specified and stop working, if you specify a testsettings file (and rebuild). I used a default test settigns file and our old testsettings file with the same result.
Do you know, who is guilty and what should I do?

P.S. I have attached my test example, if you don't want to create it by yourself.
P.P.S. I tests it on Typemock v. 7.4.
asked by Grigory (1.3k points)

4 Answers

0 votes
Hi Grigory,

The exception doesn't reproduce on our machines with the project you sent.

Please make sure that "namespaces.dat" under your Typemock installation directory contains "vstest.executionengine.clr20.exe".
In case it does, please please reproduce this exception with logs and send them to us.

In order to run Isolator with logs, open visual studio -> Typemock menu -> options -> Visual Studio tab -> enable logs.

The code below is part of our old API.
using (RecordExpectations recorder = RecorderManager.StartRecording())
    recorder.ExpectAndReturn(System.Configuration.ConfigurationManager.AppSettings.Get(""), "0");

You can use Isolate.WhenCalled() from the AAA API instead.
answered by alex (17k points)
0 votes
I forgot to say, that I use VS 2012 Professional Update 3 and Windows 2008 R2 Standart.
I called my test with "recorder.ExpectAndReturn" and with "Isolate.WhenCalled" way, but the error was the same.
I can't attache logs, because zips are too big.
You can download them from this link:
answered by Grigory (1.3k points)
0 votes
Actually, I have several failed unit tests. They all fail with different reasons, but I think, that the root of error is wrong work of Typemock with test setting files in VS 2012 (probably, for Update 3 only).
I have created a test project with 3 tests. All of them fail, if testsetting file is specified and pass, if it is not specified.
I have created typemock logs for you with fail run and success run. You can download these results and my test project from this link:
I hope it helps you to fix this error.
answered by Grigory (1.3k points)
0 votes

Thank you for the details.
We are looking into it and we'll keep you posted.
answered by alex (17k points)