@@ -1256,6 +1256,47 @@ public async Task NoMigrationDoesNotUpdateCsprojFiles()
12561256 await Assert . That ( csprojResult ) . IsEqualTo ( originalCsproj ) ;
12571257 }
12581258
1259+ [ Test ]
1260+ public async Task MigrationUsesLatestVersionNotMinVersion ( )
1261+ {
1262+ using var cache = new SourceCacheContext { RefreshMemoryCache = true } ;
1263+ var content =
1264+ """
1265+ <Project>
1266+ <ItemGroup>
1267+ <PackageVersion Include="WindowsAzure.Storage" Version="9.3.3" />
1268+ </ItemGroup>
1269+ </Project>
1270+ """ ;
1271+
1272+ using var tempFile = await TempFile . CreateText ( content ) ;
1273+
1274+ await Updater . Update ( cache , tempFile . Path , null ) ;
1275+
1276+ var result = await File . ReadAllTextAsync ( tempFile . Path ) ;
1277+ var doc = XDocument . Parse ( result ) ;
1278+
1279+ var package = doc . Descendants ( "PackageVersion" ) . Single ( ) ;
1280+ var id = package . Attribute ( "Include" ) ? . Value ;
1281+ var version = package . Attribute ( "Version" ) ? . Value ;
1282+
1283+ // Should be migrated to the alternative package
1284+ await Assert . That ( id ) . IsNotEqualTo ( "WindowsAzure.Storage" ) ;
1285+
1286+ // The migrated version should be the latest version of the alternate package,
1287+ // not the min version from the deprecation range
1288+ await Assert . That ( NuGetVersion . TryParse ( version , out var migratedVersion ) ) . IsTrue ( ) ;
1289+
1290+ var latestMetadata = await Updater . GetLatestVersion (
1291+ id ! ,
1292+ new NuGetVersion ( 0 , 0 , 0 ) ,
1293+ sources ,
1294+ cache ) ;
1295+
1296+ await Assert . That ( latestMetadata ) . IsNotNull ( ) ;
1297+ await Assert . That ( migratedVersion ! ) . IsEqualTo ( latestMetadata ! . Identity . Version ) ;
1298+ }
1299+
12591300 [ Test ]
12601301 public async Task ConcurrentRepositoryReaderAccessDoesNotThrow ( )
12611302 {
0 commit comments