@@ -300,28 +300,28 @@ public void FindCandidateExecutableFilesReturnsEmptyWhenNoCliToolExists()
300300 [ Fact ]
301301 public void PingetCliHelperDeserializesListResponsesWithGeneratedContext ( )
302302 {
303- // pinget 0.4.1+ emits snake_case keys.
303+ // Pinget emits PascalCase keys.
304304 const string json = """
305305 {
306- "matches ": [
306+ "Matches ": [
307307 {
308- "name ": "Contoso Tool",
309- "id ": "Contoso.Tool",
310- "local_id ": null,
311- "installed_version ": "1.2.3",
312- "available_version ": "2.0.0",
313- "source_name ": "winget",
314- "publisher ": null,
315- "scope ": null,
316- "installer_category ": null,
317- "install_location ": null,
318- "package_family_names ": [],
319- "product_codes ": [],
320- "upgrade_codes ": []
308+ "Name ": "Contoso Tool",
309+ "Id ": "Contoso.Tool",
310+ "LocalId ": null,
311+ "InstalledVersion ": "1.2.3",
312+ "AvailableVersion ": "2.0.0",
313+ "SourceName ": "winget",
314+ "Publisher ": null,
315+ "Scope ": null,
316+ "InstallerCategory ": null,
317+ "InstallLocation ": null,
318+ "PackageFamilyNames ": [],
319+ "ProductCodes ": [],
320+ "UpgradeCodes ": []
321321 }
322322 ],
323- "warnings ": [],
324- "truncated ": false
323+ "Warnings ": [],
324+ "Truncated ": false
325325 }
326326 """ ;
327327
@@ -335,6 +335,38 @@ public void PingetCliHelperDeserializesListResponsesWithGeneratedContext()
335335 Assert . Equal ( "winget" , match . SourceName ) ;
336336 }
337337
338+ [ Fact ]
339+ public void PingetCliHelperInfersWingetSourceWhenInstalledSourceNameIsMissing ( )
340+ {
341+ const string json = """
342+ {
343+ "Matches": [
344+ {
345+ "Name": "Contoso Tool",
346+ "Id": "ARP\\User\\X64\\Contoso.Tool_Microsoft.Winget.Source_8wekyb3d8bbwe",
347+ "LocalId": null,
348+ "InstalledVersion": "1.2.3",
349+ "AvailableVersion": null,
350+ "SourceName": null,
351+ "Publisher": "Contoso",
352+ "Scope": "User",
353+ "InstallerCategory": "exe",
354+ "InstallLocation": "C:\\Users\\example\\AppData\\Local\\Microsoft\\WinGet\\Packages\\Contoso.Tool_Microsoft.Winget.Source_8wekyb3d8bbwe",
355+ "PackageFamilyNames": [],
356+ "ProductCodes": [],
357+ "UpgradeCodes": []
358+ }
359+ ],
360+ "Warnings": [],
361+ "Truncated": false
362+ }
363+ """ ;
364+
365+ ListMatch match = Assert . Single ( PingetCliHelper . DeserializeJson < ListResponse > ( json ) . Matches ) ;
366+
367+ Assert . Equal ( "winget" , PingetCliHelper . InferSourceName ( match ) ) ;
368+ }
369+
338370 [ Fact ]
339371 public void GetCliToolPreferenceUsesEnvironmentBeforeSettings ( )
340372 {
0 commit comments