@@ -16,29 +16,37 @@ public HtmlDifferenceEngine(IDiffingStrategy diffingStrategy)
1616 _diffingStrategy = diffingStrategy ?? throw new ArgumentNullException ( nameof ( diffingStrategy ) ) ;
1717 }
1818
19- public IEnumerable < IDiff > Compare ( INodeList controlNodes , INodeList testNodes )
19+ public IEnumerable < IDiff > Compare ( INode controlNode , INode testNode )
20+ {
21+ if ( controlNode is null ) throw new ArgumentNullException ( nameof ( controlNode ) ) ;
22+ if ( testNode is null ) throw new ArgumentNullException ( nameof ( testNode ) ) ;
23+
24+ return Compare ( new [ ] { controlNode } , new [ ] { testNode } ) ;
25+ }
26+
27+ public IEnumerable < IDiff > Compare ( IEnumerable < INode > controlNodes , IEnumerable < INode > testNodes )
2028 {
2129 if ( controlNodes is null ) throw new ArgumentNullException ( nameof ( controlNodes ) ) ;
2230 if ( testNodes is null ) throw new ArgumentNullException ( nameof ( testNodes ) ) ;
2331
2432 var controlSources = controlNodes . ToSourceCollection ( ComparisonSourceType . Control ) ;
2533 var testSources = testNodes . ToSourceCollection ( ComparisonSourceType . Test ) ;
2634
27- var context = CreateDiffContext ( controlNodes , testNodes ) ;
35+ var context = CreateDiffContext ( controlSources , testSources ) ;
2836
2937 var diffs = CompareNodeLists ( context , controlSources , testSources ) ;
3038 var unmatchedDiffs = context . GetDiffsFromUnmatched ( ) ;
3139
3240 return diffs . Concat ( unmatchedDiffs ) ;
3341 }
3442
35- private static DiffContext CreateDiffContext ( INodeList controlNodes , INodeList testNodes )
43+ private static DiffContext CreateDiffContext ( SourceCollection controlNodes , SourceCollection testNodes )
3644 {
3745 IElement ? controlRoot = null ;
3846 IElement ? testRoot = null ;
3947
40- if ( controlNodes . Length > 0 && controlNodes [ 0 ] . GetRoot ( ) is IElement r1 ) { controlRoot = r1 ; }
41- if ( testNodes . Length > 0 && testNodes [ 0 ] . GetRoot ( ) is IElement r2 ) { testRoot = r2 ; }
48+ if ( controlNodes . Count > 0 && controlNodes . First ( ) . Node . GetRoot ( ) is IElement r1 ) { controlRoot = r1 ; }
49+ if ( testNodes . Count > 0 && testNodes . First ( ) . Node . GetRoot ( ) is IElement r2 ) { testRoot = r2 ; }
4250
4351 return new DiffContext ( controlRoot , testRoot ) ;
4452 }
0 commit comments