@@ -720,6 +720,81 @@ public void GetSourceFiles_ShouldGiveError_ForIncompatibleNewerVersion()
720
720
ex ! . Message . Should ( ) . StartWith ( "This source code was published with a newer, incompatible version of Bicep (0.whatever.0). You are using version " ) ;
721
721
}
722
722
723
+ [ TestMethod ]
724
+ public void FindDocumentLinks_DocumentLinksNotFound_ReturnsEmptyArray ( )
725
+ {
726
+ var result = CreateSourceArchiveResult (
727
+ (
728
+ "__metadata.json" ,
729
+ """
730
+ {
731
+ "entryPoint": "child.bicep",
732
+ "metadataVersion": 1,
733
+ "bicepVersion": "0.34.1",
734
+ "sourceFiles": [
735
+ {
736
+ "path": "child.bicep",
737
+ "archivePath": "files/child.bicep",
738
+ "kind": "bicep"
739
+ }
740
+ ],
741
+ "documentLinks": {}
742
+ }
743
+ """
744
+ ) ,
745
+ (
746
+ "child.bicep" ,
747
+ "bicep contents"
748
+ )
749
+ ) . UnwrapOrThrow ( ) ;
750
+
751
+ var documentLinks = result . FindDocumentLinks ( "child.bicep" ) ;
752
+
753
+ documentLinks . Should ( ) . BeEmpty ( ) ;
754
+ }
755
+
756
+ [ TestMethod ]
757
+ public void FindDocumentLinks_DocumentLinksFound_ReturnsNonEmptyArray ( )
758
+ {
759
+ var result = CreateSourceArchiveResult (
760
+ (
761
+ "__metadata.json" ,
762
+ """
763
+ {
764
+ "entryPoint": "child.bicep",
765
+ "metadataVersion": 1,
766
+ "bicepVersion": "0.34.1",
767
+ "sourceFiles": [
768
+ {
769
+ "path": "child.bicep",
770
+ "archivePath": "files/child.bicep",
771
+ "kind": "bicep"
772
+ }
773
+ ],
774
+ "documentLinks": {
775
+ "dummy.bicep": [
776
+ {
777
+ "range": "[0:1]-[2:4]",
778
+ "target": "foobar.bicep"
779
+ }
780
+ ]
781
+ }
782
+ }
783
+ """
784
+ ) ,
785
+ (
786
+ "child.bicep" ,
787
+ "bicep contents"
788
+ )
789
+ ) . UnwrapOrThrow ( ) ;
790
+
791
+ var documentLinks = result . FindDocumentLinks ( "dummy.bicep" ) ;
792
+
793
+ documentLinks . Should ( ) . HaveCount ( 1 ) ;
794
+ documentLinks [ 0 ] . Range . ToString ( ) . Should ( ) . Be ( "[0:1]-[2:4]" ) ;
795
+ documentLinks [ 0 ] . Target . Should ( ) . Be ( "foobar.bicep" ) ;
796
+ }
797
+
723
798
private ResultWithException < SourceArchive > CreateSourceArchiveResult ( params ( string relativePath , string contents ) [ ] files )
724
799
{
725
800
var stream = new MemoryStream ( ) ;
0 commit comments