44using System . Linq ;
55using System . Text . RegularExpressions ;
66using ImpromptuInterface ;
7+ using ImpromptuInterface . InvokeExt ;
78
89namespace TechTalk . SpecFlow . Assist
910{
@@ -14,13 +15,13 @@ public static class DynamicTableHelpers
1415 private const string ERRORMESS_NOT_ON_TABLE = "The '{0}' value not present in the table, but on the instance" ;
1516 private const string ERRORMESS_NOT_ON_INSTANCE = "The '{0}' value not present on the instance, but in the table" ;
1617 private const string ERRORMESS_VALUE_DIFFERS =
17- "The '{0}' value differs from table and instance.\n \t Instance:\t '{1}'.\n \t Table:\t \t '{2}' " ;
18+ "The '{0}' value differs from table and instance.\n \t Instance:\t '{1}'(type: {2}) .\n \t Table:\t \t '{3}'(type: {4}) " ;
1819
1920 private const string ERRORMESS_NUMBER_OF_ROWS_DIFFERS =
2021 "Number of rows for table ({0} rows) and set ({1} rows) differs" ;
2122
2223 private const string ERRORMESS_SET_VALUES_DIFFERS =
23- "A difference was found on row '{0}' for column '{1}' (property '{2}').\n \t Instance:\t '{3}'.\n \t Table:\t \t '{4}' " ;
24+ "A difference was found on row '{0}' for column '{1}' (property '{2}').\n \t Instance:\t '{3}'(type: {4}) .\n \t Table:\t \t '{5}'(type: {6}) " ;
2425
2526 /// <summary>
2627 /// Create a dynamic object from the headers and values of the <paramref name="table"/>
@@ -109,21 +110,25 @@ private static List<string> GetSetValueDifferences(Table table, IList<object> se
109110 {
110111 foreach ( var memberName in memberNames )
111112 {
112- var currentHeader = string . Empty ;
113- var rowValue = GetRowValue ( i , table , memberName , out currentHeader , doTypeConversion ) ;
114- var instanceValue = Impromptu . InvokeGet ( set [ i ] , memberName ) ;
115-
116- if ( ! instanceValue . Equals ( rowValue ) )
117- {
118- var difference = string . Format ( ERRORMESS_SET_VALUES_DIFFERS ,
119- i + 1 ,
120- currentHeader ,
121- memberName ,
122- instanceValue ,
123- rowValue ) ;
124-
125- valueDifference . Add ( difference ) ;
126- }
113+ var currentHeader = string . Empty ;
114+ var rowValue = GetRowValue ( i , table , memberName , out currentHeader , doTypeConversion ) ;
115+ var rowType = rowValue . GetType ( ) . Name ;
116+ var instanceValue = Impromptu . InvokeGet ( set [ i ] , memberName ) ;
117+ var instanceType = instanceValue . GetType ( ) . Name ;
118+
119+ if ( ! instanceValue . Equals ( rowValue ) )
120+ {
121+ var difference = string . Format ( ERRORMESS_SET_VALUES_DIFFERS ,
122+ i + 1 ,
123+ currentHeader ,
124+ memberName ,
125+ instanceValue ,
126+ instanceType ,
127+ rowValue ,
128+ rowType ) ;
129+
130+ valueDifference . Add ( difference ) ;
131+ }
127132 }
128133 }
129134 return valueDifference ;
@@ -177,11 +182,13 @@ private static IList<string> ValidateValuesOfRow(TableRow tableRow, dynamic inst
177182 {
178183 var propertyName = CreatePropertyName ( header ) ;
179184 var valueFromInstance = Impromptu . InvokeGet ( instance , propertyName ) ;
185+ var typeFromInstance = valueFromInstance . GetType ( ) . Name ;
180186 var valueFromTable = CreateTypedValue ( tableRow [ header ] , doTypeConversion ) ;
187+ var typeFromTable = valueFromTable . GetType ( ) . Name ;
181188
182189 if ( ! valueFromInstance . Equals ( valueFromTable ) )
183190 {
184- var mess = string . Format ( ERRORMESS_VALUE_DIFFERS , propertyName , valueFromInstance , valueFromTable ) ;
191+ var mess = string . Format ( ERRORMESS_VALUE_DIFFERS , propertyName , valueFromInstance , typeFromInstance , valueFromTable , typeFromTable ) ;
185192 valueDiffs . Add ( mess ) ;
186193 }
187194 }
0 commit comments