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
Hi,

In few code areas we have Debug.Assert which Assert during unit test. This cause unit test to fail. For this I have mocked the Debug.Assert as shown below. This works when running in debug mode.

         using (RecordExpectations recorder = RecorderManager.StartRecording())
         {
            Debug.Assert(false);
            recorder.RepeatAlways();
         }


However when running in integration environment like cruise control it throws and error.

Cannot use RepeatAlways in this sequence, there must be a mocked statement first Perhaps you are trying to mock a method from mscorlib
asked by bhaveshbusa (1.2k points)

2 Answers

0 votes
Hi bhaveshbusa,

When compiled in Release mode, Debug.Assert() is not inserted to your program code, and this is why in release mode Isolator cannot find any statements in the recording block. As a workaround, you can put this recording block inside an #ifdef DEBUG -- #endif block, meaning the recording block will not be compiled into release code either.

Please let me know if this helps.

Regards,
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
Thanks. I will be using the ConditionalAttribute on the isolate method to make it look more neat.
answered by bhaveshbusa (1.2k points)
...