@@ -79,6 +79,15 @@ public void StringEquality()
79
79
first . Should ( ) . Be ( second ) ;
80
80
}
81
81
82
+ [ U ]
83
+ public void StringInequality ( )
84
+ {
85
+ Field first = "Name" ;
86
+ Field second = "name" ;
87
+
88
+ first . Should ( ) . NotBe ( second ) ;
89
+ }
90
+
82
91
[ U ]
83
92
public void Expression ( )
84
93
{
@@ -159,8 +168,7 @@ public void ExpressionWithDictionaryItemVariableExpression()
159
168
resolved . Should ( ) . Contain ( key ) ;
160
169
}
161
170
162
- [ U ]
163
- public void ExpressionWithDictionaryItemConstantExpression ( )
171
+ [ U ] public void ExpressionWithDictionaryItemConstantExpression ( )
164
172
{
165
173
var resolver = new TestableFieldResolver ( new ConnectionSettings ( ) ) ;
166
174
var resolved = resolver . Resolve ( Field < Project > ( p => p . Metadata [ "key1" ] ) ) ;
@@ -171,6 +179,19 @@ public void ExpressionWithDictionaryItemConstantExpression()
171
179
resolved . Should ( ) . Contain ( "key2" ) ;
172
180
}
173
181
182
+ [ U ] public void ExpressionWithDictionaryItemConstantExpressionAndVariableSuffix ( )
183
+ {
184
+ var resolver = new TestableFieldResolver ( new ConnectionSettings ( ) ) ;
185
+ var suffix = "x" ;
186
+ var resolved = resolver . Resolve ( Field < Project > ( p => p . Metadata [ "key1" ] . Suffix ( suffix ) ) ) ;
187
+ resolver . CachedFields . Should ( ) . Be ( 0 ) ;
188
+ resolved . Should ( ) . Contain ( "key1" ) . And . EndWith ( ".x" ) ;
189
+ suffix = "y" ;
190
+ resolved = resolver . Resolve ( Field < Project > ( p => p . Metadata [ "key2" ] . Suffix ( suffix ) ) ) ;
191
+ resolver . CachedFields . Should ( ) . Be ( 0 ) ;
192
+ resolved . Should ( ) . Contain ( "key2" ) . And . EndWith ( ".y" ) ;
193
+ }
194
+
174
195
[ U ]
175
196
public void ExpressionWithDictionarySuffix ( )
176
197
{
@@ -217,7 +238,7 @@ public void PropertyInfo()
217
238
resolver . Resolve ( ( Field ) typeof ( Project ) . GetProperty ( nameof ( Project . Name ) ) ) ;
218
239
resolver . CachedFields . Should ( ) . Be ( 1 ) ;
219
240
resolver . Resolve ( ( Field ) typeof ( Project ) . GetProperty ( nameof ( Project . Name ) ) ) ;
220
- resolver . CachedFields . Should ( ) . Be ( 1 ) ; ;
241
+ resolver . CachedFields . Should ( ) . Be ( 1 ) ;
221
242
}
222
243
223
244
[ U ]
@@ -280,6 +301,14 @@ public void PropertyInfoEquality()
280
301
first . Should ( ) . Be ( second ) ;
281
302
}
282
303
304
+ [ U ]
305
+ public void PropertyInfoInequality ( )
306
+ {
307
+ PropertyName first = typeof ( Project ) . GetProperty ( nameof ( Project . Name ) ) ;
308
+ PropertyName second = typeof ( Project ) . GetProperty ( nameof ( Project . NumberOfCommits ) ) ;
309
+
310
+ first . Should ( ) . NotBe ( second ) ;
311
+ }
283
312
[ U ]
284
313
public void StringEquality ( )
285
314
{
@@ -381,7 +410,7 @@ public CachePerformance(ITestOutputHelper output)
381
410
public class HitTiming
382
411
{
383
412
public string Name { get ; set ; }
384
- public Field Field { get ; set ; }
413
+ public Func < Field > Field { get ; set ; }
385
414
public double FirstHit { get ; set ; }
386
415
public double CachedHit { get ; set ; }
387
416
@@ -397,39 +426,39 @@ public void CachedVsNonCached()
397
426
{
398
427
_resolver = new FieldResolver ( new ConnectionSettings ( ) ) ;
399
428
400
- AddTiming ( Field < Project > ( p => p . Metadata [ "fixed" ] ) ) ;
429
+ AddTiming ( ( ) => Field < Project > ( p => p . Metadata [ "fixed" ] ) ) ;
401
430
var x = "dynamic" ;
402
- AddTiming ( Field < Project > ( p => p . Metadata [ x ] ) ) ;
403
- AddTiming ( Field < Project > ( p => p . Name ) ) ;
404
- AddTiming ( Field < Project > ( p => p . Description ) ) ;
405
- AddTiming ( Field < Project > ( p => p . NumberOfCommits ) ) ;
406
- AddTiming ( Field < Project > ( p => p . LastActivity ) ) ;
407
- AddTiming ( Field < Project > ( p => p . LeadDeveloper ) ) ;
408
- AddTiming ( Field < Project > ( p => p . Metadata ) ) ;
409
- AddTiming ( Field < Project > ( p => p . Tags ) ) ;
410
- AddTiming ( Field < Project > ( p => p . CuratedTags ) ) ;
411
-
412
- AddTiming ( Field < CommitActivity > ( p => p . Id ) ) ;
413
- AddTiming ( Field < CommitActivity > ( p => p . Message ) ) ;
414
- AddTiming ( Field < CommitActivity > ( p => p . ProjectName ) ) ;
415
- AddTiming ( Field < CommitActivity > ( p => p . StringDuration ) ) ;
431
+ AddTiming ( ( ) => Field < Project > ( p => p . Metadata [ x ] ) ) ;
432
+ AddTiming ( ( ) => Field < Project > ( p => p . Name ) ) ;
433
+ AddTiming ( ( ) => Field < Project > ( p => p . Description ) ) ;
434
+ AddTiming ( ( ) => Field < Project > ( p => p . NumberOfCommits ) ) ;
435
+ AddTiming ( ( ) => Field < Project > ( p => p . LastActivity ) ) ;
436
+ AddTiming ( ( ) => Field < Project > ( p => p . LeadDeveloper ) ) ;
437
+ AddTiming ( ( ) => Field < Project > ( p => p . Metadata ) ) ;
438
+ AddTiming ( ( ) => Field < Project > ( p => p . Tags ) ) ;
439
+ AddTiming ( ( ) => Field < Project > ( p => p . CuratedTags ) ) ;
440
+
441
+ AddTiming ( ( ) => Field < CommitActivity > ( p => p . Id ) ) ;
442
+ AddTiming ( ( ) => Field < CommitActivity > ( p => p . Message ) ) ;
443
+ AddTiming ( ( ) => Field < CommitActivity > ( p => p . ProjectName ) ) ;
444
+ AddTiming ( ( ) => Field < CommitActivity > ( p => p . StringDuration ) ) ;
416
445
417
446
output . WriteLine ( _timings . Aggregate ( new StringBuilder ( ) . AppendLine ( ) , ( sb , s ) => sb . AppendLine ( s . ToString ( ) ) , sb => sb . ToString ( ) ) ) ;
418
447
}
419
448
420
- private void AddTiming ( Field field )
449
+ private void AddTiming ( Func < Field > field )
421
450
{
422
451
var timing = new HitTiming { Field = field } ;
423
452
_timings . Add ( timing ) ;
424
453
425
454
_stopwatch = Stopwatch . StartNew ( ) ;
426
455
427
- timing . Name = _resolver . Resolve ( field ) ;
456
+ timing . Name = _resolver . Resolve ( field ( ) ) ;
428
457
timing . FirstHit = _stopwatch . Elapsed . TotalMilliseconds ;
429
458
430
459
_stopwatch . Restart ( ) ;
431
460
432
- _resolver . Resolve ( field ) ;
461
+ _resolver . Resolve ( field ( ) ) ;
433
462
timing . CachedHit = _stopwatch . Elapsed . TotalMilliseconds ;
434
463
435
464
_stopwatch . Stop ( ) ;
0 commit comments