@@ -259,5 +259,60 @@ private string[] ExpandExpectationShortHand(string[] input)
259
259
260
260
return output ;
261
261
}
262
+
263
+ [ WindowsOnlyFact ]
264
+ internal void TestUninstallableStringsCorrectManySDKs ( )
265
+ {
266
+ var bundles = new List < Bundle >
267
+ {
268
+ new Bundle < SdkVersion > ( new SdkVersion ( "3.0.100-preview-0" ) , BundleArch . X64 , string . Empty , "3.0.100" ) ,
269
+ new Bundle < RuntimeVersion > ( new RuntimeVersion ( "2.0.0" ) , BundleArch . X64 , string . Empty , "2.0.0" ) ,
270
+ } ;
271
+
272
+ for ( int i = 0 ; i < 5 ; i ++ )
273
+ {
274
+ bundles . Add ( new Bundle < SdkVersion > ( new SdkVersion ( "2.0." + i ) , BundleArch . X64 , string . Empty , "2.0." + i ) ) ;
275
+ bundles . Add ( new Bundle < SdkVersion > ( new SdkVersion ( "2.0." + i + "-preview-0" ) , BundleArch . X64 , string . Empty , "2.0." + i + "-preview-0" ) ) ;
276
+ bundles . Add ( new Bundle < SdkVersion > ( new SdkVersion ( "2.0." + i + "-preview-1" ) , BundleArch . X64 , string . Empty , "2.0." + i + "-preview-1" ) ) ;
277
+ }
278
+
279
+ var strings = VisualStudioSafeVersionsExtractor . GetReasonRequiredStrings ( bundles ) ;
280
+ strings . Count . Should ( ) . Be ( bundles . Count ) ;
281
+
282
+ var expectedProtected = new string [ ] { "3.0.100" , "2.0.4" } ;
283
+ AssertRequirementStringsCorrect ( bundles , strings , expectedProtected ) ;
284
+ }
285
+
286
+ [ WindowsOnlyFact ]
287
+ internal void TestUninstallableStringsCorrectAcrossRequirementDivisions ( )
288
+ {
289
+ var bundles = new List < Bundle >
290
+ {
291
+ new Bundle < SdkVersion > ( new SdkVersion ( "2.0.0" ) , BundleArch . X64 , string . Empty , "2.0.0" ) ,
292
+ new Bundle < SdkVersion > ( new SdkVersion ( "2.0.0-preview-0" ) , BundleArch . X64 , string . Empty , "2.0.0-preview-0" ) ,
293
+ new Bundle < SdkVersion > ( new SdkVersion ( "2.0.0-preview-1" ) , BundleArch . X64 , string . Empty , "2.0.0-preview-1" )
294
+ } ;
295
+
296
+ var strings = VisualStudioSafeVersionsExtractor . GetReasonRequiredStrings ( bundles ) ;
297
+ var expectedProtected = new string [ ] { "2.0.0" } ;
298
+ AssertRequirementStringsCorrect ( bundles , strings , expectedProtected ) ;
299
+ }
300
+
301
+ private void AssertRequirementStringsCorrect ( List < Bundle > bundles , Dictionary < Bundle , string > bundleStringPairs , string [ ] expectedProtected )
302
+ {
303
+ bundleStringPairs . Count . Should ( ) . Be ( bundles . Count ) ;
304
+
305
+ var expectedUninstallable = bundles . Select ( bundle => bundle . DisplayName )
306
+ . Except ( expectedProtected ) ;
307
+
308
+ bundleStringPairs . Where ( pair => pair . Key . Version is SdkVersion )
309
+ . Where ( pair => string . IsNullOrEmpty ( pair . Value ) )
310
+ . Select ( pair => pair . Key . DisplayName )
311
+ . Should ( ) . BeEquivalentTo ( expectedUninstallable ) ;
312
+
313
+ bundleStringPairs . Where ( pair => ! string . IsNullOrEmpty ( pair . Value ) )
314
+ . Select ( pair => pair . Key . DisplayName )
315
+ . Should ( ) . BeEquivalentTo ( expectedProtected ) ;
316
+ }
262
317
}
263
318
}
0 commit comments