@@ -16,29 +16,37 @@ public HtmlDifferenceEngine(IDiffingStrategy diffingStrategy)
16
16
_diffingStrategy = diffingStrategy ?? throw new ArgumentNullException ( nameof ( diffingStrategy ) ) ;
17
17
}
18
18
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 )
20
28
{
21
29
if ( controlNodes is null ) throw new ArgumentNullException ( nameof ( controlNodes ) ) ;
22
30
if ( testNodes is null ) throw new ArgumentNullException ( nameof ( testNodes ) ) ;
23
31
24
32
var controlSources = controlNodes . ToSourceCollection ( ComparisonSourceType . Control ) ;
25
33
var testSources = testNodes . ToSourceCollection ( ComparisonSourceType . Test ) ;
26
34
27
- var context = CreateDiffContext ( controlNodes , testNodes ) ;
35
+ var context = CreateDiffContext ( controlSources , testSources ) ;
28
36
29
37
var diffs = CompareNodeLists ( context , controlSources , testSources ) ;
30
38
var unmatchedDiffs = context . GetDiffsFromUnmatched ( ) ;
31
39
32
40
return diffs . Concat ( unmatchedDiffs ) ;
33
41
}
34
42
35
- private static DiffContext CreateDiffContext ( INodeList controlNodes , INodeList testNodes )
43
+ private static DiffContext CreateDiffContext ( SourceCollection controlNodes , SourceCollection testNodes )
36
44
{
37
45
IElement ? controlRoot = null ;
38
46
IElement ? testRoot = null ;
39
47
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 ; }
42
50
43
51
return new DiffContext ( controlRoot , testRoot ) ;
44
52
}
0 commit comments