Unit test: How best to provide an XML input?

Posted by TheSilverBullet on Programmers See other posts from Programmers or by TheSilverBullet
Published on 2012-11-12T08:35:04Z Indexed on 2012/11/12 11:20 UTC
Read the original article Hit count: 267

Filed under:
|
|

I need to write a unit test which validates the serialization of two attributes of an XML(size ~ 30 KB) file.

What is the best way to provide an input for this test?

Here are the options I have considered:

  1. Add the file to the project and use a file reader
  2. Pass the contents of the XML as a string
  3. Create the XML through a program and pass it

Which is my best option and why? If there is another way which you think is better, I would love to hear it.

© Programmers or respective owner

Related posts about unit-testing

Related posts about asp.net-mvc