I use a stream reader to import some data, and at the moment I'm hard-coded to set a small sample file in the test for the job.
Can I use Mock Objects with this and how?
I do not see any points to make fun of StreamReader if you are not making a StreamReader class. If you need to provide test input through StreamReader, just read some predefined data from any suitable source.
StreamReader is a concrete class, therefore many mocking systems will not allow you to mock it. TypeMock Isolator , however.
, , , . , StreamReader , MemoryStream - .
When testing code that depends on streams, streams, and streaming, I usually use the memystream object for testing. There is no mocking structure.
You can use the factory method to return a TextReader, which can be either a mockup or an actual StreamReader.
Source: https://habr.com/ru/post/1696859/More articles:Переключение редакторов в Eclipse с помощью клавиатуры, а не переключение Design/Source - eclipseЕсть ли способ асинхронно фильтровать IList? - javascriptBad address error from copy_to_user - cIs there a transformation mechanism or library using .NET? - c #Flexible compiler pipeline definitions - compiler-constructionMerging Entries for Mnesia - erlangWhat are the best practices for the Middleware API? - javaDevExpress eXpressApp Framework (XAF) and Permanent eXpress Objects (XPO): how to speed up association load times? - devexpressGeneral / static variable in Global.asax separately for request? - vb.netEvery Linux distribution comes with gcc / g ++ 4. * nowadays? - c ++All Articles