开发者

Unit Testing GetManifestResourceStream

Quick question about unit testing.

My application has a few embeded Xml files, they are often added and sometimes removed. I have a method that I want to unit test that contains the line

Assembly.GetExecutingAssembly().GetManifestResourceStream(xmlFile)

xmlFile is a parameter

Because of this the t开发者_JAVA百科est will become dependent on a particular xml file being there, and there is a chance it could be removed at a later date, which is fine, but would break my test when really it shouldn't.

Does anybody know anyway around this dependency other than removing this line of code and passing it into the method instead (That will only mean I have to test it else where).

Thanks


Use GetManifestResourceNames(). Only run the test on the names you discover this way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜