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.
+1 vote
I am a newbie so these questions may be real basic. I am using the community edition so I cannot use the natural typemocks.

I am trying to mock the class File and another class StreamReader.

MockManager.Init();

Mock fMock = MockManager.Mock( typeof( File ), Constructor.StaticNotMocked );
MockObject srMock = MockManager.MockObject( typeof( StreamReader ), Constructor.Mocked, typeof( string ) );
//Mock srMock = MockManager.Mock( typeof( StreamReader ), Constructor.Mocked );
fMock.ExpectAndReturn( "OpenText", srMock.MockedInstance, typeof( string ) );

I have tried to use both the MockManager.Mock and MockManager.MockObject with StreamReader and I keep getting the error I listed in the subject line when I try to create the srMock object. What am I doing wrong?

Also, when should I use MockManager.Mock and MockManager.MockObject; what is the difference?

Thanks
asked by dalHome (730 points)

24 Answers

0 votes
I would very much like to be able to mock System.IO.File, System.IO.FileInfo, System.IO.Directory, System.IO.DirectoryInfo, and System.Threading.Task classes

This currently is a huge block to me because of the nature of the code I am trying to mock, which completely relies upon the before mentioned classes.

Thanks.
answered by ahives (180 points)
0 votes
Hi,

We're extending our support in mscorlib types, most of the types you requested will be available in our next version :D

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
0 votes
Could you guys please add support for the System.Environment class? Looking to unit test some code that deals with environment variables.
answered by jayzee (140 points)
0 votes
Hi Jay-Z,

Yes we can.

It will be included in one of the upcoming versions.

Regards,
Yonatan,
Typemock Support
answered by yonatan (1.6k points)
...