开发者

Unit Testing VS 2008 Using Excel

When using Excel (2003) to provide data for my unit tests it seems to think that when a cell has TRUE / FALSE value that it is null when there has been no preceding cell values e.g.

 if (TestContext.DataRow["SatisfactionExtremelySatisfied"] != DBNull.Value)
      model.SatisfactionExtremelySatisfied开发者_开发技巧 = (bool)TestContext.DataRow
      ["SatisfactionExtremelySatisfied"];

Sample Excel Data

DataRow  SatisfactionExtremelySatisfied
0
1
2                 TRUE
3                 TRUE

When reading the test data using OLEDB the cells with TRUE hold no value (when inspected in debug) but when the preceding cells have the value FALSE entered it correctly gets the values TRUE.

Am I missing something?


Simplify.

Save the excel spreadsheet as a plain text .csv file, and have your test framework read that. Otherwise, you're complicating your tests by troubleshooting the nuances of reading from Excel.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜