@@ -86,5 +86,39 @@ public void ReturnsNull_WhenExactModuleVersionIsNotInstalled()
8686
8787 Assert . Null ( result ) ;
8888 }
89+
90+ // Any version with a postfix starting with '-' will be considered a preview version.
91+ // Preview versions may be installed into a folder with the base version name, without the postfix
92+ // (for example '4.0.2-preview' may be installed into a folder with the name '4.0.2'),
93+ // so we need to take this into account and look for both.
94+ [ Theory ]
95+ [ InlineData ( "-preview" ) ]
96+ [ InlineData ( "-alfa" ) ]
97+ [ InlineData ( "-prerelease" ) ]
98+ [ InlineData ( "-anything" ) ]
99+ public void ReturnsLatestSnapshotPath_WhenPreviewVersionInstalled ( string postfix )
100+ {
101+ var baseVersion = "4.0.2" ;
102+ var fullVersion = baseVersion + postfix ;
103+
104+ DependencyManifestEntry [ ] dependencyManifestEntries =
105+ {
106+ new DependencyManifestEntry ( "A" , VersionSpecificationType . ExactVersion , fullVersion )
107+ } ;
108+
109+ _mockStorage . Setup ( _ => _ . GetDependencies ( ) ) . Returns ( dependencyManifestEntries ) ;
110+
111+ _mockStorage . Setup ( _ => _ . GetLatestInstalledSnapshot ( ) ) . Returns ( "snapshot" ) ;
112+
113+ // No exact match...
114+ _mockStorage . Setup ( _ => _ . IsModuleVersionInstalled ( "snapshot" , "A" , fullVersion ) ) . Returns ( false ) ;
115+ // ...but the base version is here
116+ _mockStorage . Setup ( _ => _ . IsModuleVersionInstalled ( "snapshot" , "A" , baseVersion ) ) . Returns ( true ) ;
117+
118+ var installedDependenciesLocator = new InstalledDependenciesLocator ( _mockStorage . Object ) ;
119+ var result = installedDependenciesLocator . GetPathWithAcceptableDependencyVersionsInstalled ( ) ;
120+
121+ Assert . Equal ( "snapshot" , result ) ;
122+ }
89123 }
90124}
0 commit comments