@@ -446,5 +446,83 @@ public void IsDateTimePlaceholder_Element_IsDateTime_CustomFormat() {
446446
447447 Assert . IsFalse ( diff . HasDifferences ( ) ) ;
448448 }
449+
450+ [ Test ]
451+ public void CanCompareDocmentsWithXsiTypes ( ) {
452+ string control = "<element"
453+ + " xmlns:myns=\" https://example.org/some-ns\" "
454+ + " xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" "
455+ + " xsi:type=\" myns:some-type\" />" ;
456+ string test = "<element"
457+ + " xmlns:myns=\" https://example.org/some-ns\" "
458+ + " xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" "
459+ + " xsi:type=\" myns:some-other-type\" />" ;
460+
461+ var diff = DiffBuilder . Compare ( control ) . WithTest ( test )
462+ . WithDifferenceEvaluator ( new PlaceholderDifferenceEvaluator ( ) . Evaluate ) . Build ( ) ;
463+
464+ Assert . IsTrue ( diff . HasDifferences ( ) ) ;
465+ int count = 0 ;
466+ foreach ( Difference difference in diff . Differences ) {
467+ count ++ ;
468+ Assert . AreEqual ( ComparisonResult . DIFFERENT , difference . Result ) ;
469+ Assert . AreEqual ( ComparisonType . ATTR_VALUE , difference . Comparison . Type ) ;
470+ }
471+ Assert . AreEqual ( 1 , count ) ;
472+ }
473+
474+ [ Test ]
475+ public void CanIgnoreXsiTypeDifference ( )
476+ {
477+ string control = "<element"
478+ + " xmlns:myns=\" https://example.org/some-ns\" "
479+ + " xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" "
480+ + " xsi:type=\" myns:${xmlunit.ignore}\" />" ;
481+ string test = "<element"
482+ + " xmlns:myns=\" https://example.org/some-ns\" "
483+ + " xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" "
484+ + " xsi:type=\" myns:some-other-type\" />" ;
485+
486+ var diff = DiffBuilder . Compare ( control ) . WithTest ( test )
487+ . WithDifferenceEvaluator ( new PlaceholderDifferenceEvaluator ( ) . Evaluate ) . Build ( ) ;
488+
489+ Assert . IsFalse ( diff . HasDifferences ( ) ) ;
490+ }
491+
492+ [ Test ]
493+ public void CantIgnoreXsiNamespaceDifference ( )
494+ {
495+ string control = "<element"
496+ + " xmlns:myns=\" https://example.org/some-other-ns\" "
497+ + " xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" "
498+ + " xsi:type=\" myns:${xmlunit.ignore}\" />" ;
499+ string test = "<element"
500+ + " xmlns:myns=\" https://example.org/some-ns\" "
501+ + " xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" "
502+ + " xsi:type=\" myns:some-other-type\" />" ;
503+
504+ var diff = DiffBuilder . Compare ( control ) . WithTest ( test )
505+ . WithDifferenceEvaluator ( new PlaceholderDifferenceEvaluator ( ) . Evaluate ) . Build ( ) ;
506+
507+ Assert . IsTrue ( diff . HasDifferences ( ) ) ;
508+ }
509+
510+ [ Test ]
511+ public void CanCompareXsiTypeWithhRegex ( )
512+ {
513+ string control = "<element"
514+ + " xmlns:myns=\" https://example.org/some-ns\" "
515+ + " xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" "
516+ + " xsi:type=\" myns:${xmlunit.matchesRegex(.*-type)}\" />" ;
517+ string test = "<element"
518+ + " xmlns:myns=\" https://example.org/some-ns\" "
519+ + " xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" "
520+ + " xsi:type=\" myns:some-other-type\" />" ;
521+
522+ var diff = DiffBuilder . Compare ( control ) . WithTest ( test )
523+ . WithDifferenceEvaluator ( new PlaceholderDifferenceEvaluator ( ) . Evaluate ) . Build ( ) ;
524+
525+ Assert . IsFalse ( diff . HasDifferences ( ) ) ;
526+ }
449527 }
450528}
0 commit comments