Unit Testing VS 2008 Using Excel
        Posted  
        
            by David
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by David
        
        
        
        Published on 2010-05-02T15:22:46Z
        Indexed on 
            2010/05/02
            15:27 UTC
        
        
        Read the original article
        Hit count: 258
        
unit-testing
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 but when the preceding cells have the value FALSE entered it correctly gets the values TRUE.
Am I missing something?
© Stack Overflow or respective owner