From 87fb88f3921976f6727f64af39d13707b29e56a0 Mon Sep 17 00:00:00 2001 From: Eric StJohn Date: Wed, 4 Dec 2024 13:59:13 -0800 Subject: [PATCH] Test that PackageDownloads are DevDependencies Also fix up some other misuses of AllSatisfy. --- .../NuGetPackageReferenceFrameworkAwareDetectorTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.ComponentDetection.Detectors.Tests/nuget/NuGetPackageReferenceFrameworkAwareDetectorTests.cs b/test/Microsoft.ComponentDetection.Detectors.Tests/nuget/NuGetPackageReferenceFrameworkAwareDetectorTests.cs index 2171ce80..dc4cbf19 100644 --- a/test/Microsoft.ComponentDetection.Detectors.Tests/nuget/NuGetPackageReferenceFrameworkAwareDetectorTests.cs +++ b/test/Microsoft.ComponentDetection.Detectors.Tests/nuget/NuGetPackageReferenceFrameworkAwareDetectorTests.cs @@ -276,7 +276,7 @@ public async Task ScanDirectoryAsync_ExcludedFrameworkComponent_8_0_web_Verifica .ExecuteDetectorAsync(); var detectedComponents = componentRecorder.GetDetectedComponents(); - detectedComponents.Should().AllSatisfy(c => componentRecorder.GetEffectiveDevDependencyValue(c.Component.Id).GetValueOrDefault(), "All should be development dependencies"); + detectedComponents.Should().AllSatisfy(c => componentRecorder.GetEffectiveDevDependencyValue(c.Component.Id).Should().BeTrue(), "All should be development dependencies"); } [TestMethod] @@ -289,7 +289,7 @@ public async Task ScanDirectoryAsync_ExcludedFrameworkComponent_42_15_web_Verifi // net42.15 is not a known framework, but it can import framework packages from the closest known framework. var detectedComponents = componentRecorder.GetDetectedComponents(); - detectedComponents.Should().AllSatisfy(c => componentRecorder.GetEffectiveDevDependencyValue(c.Component.Id).GetValueOrDefault(), "All should be development dependencies"); + detectedComponents.Should().AllSatisfy(c => componentRecorder.GetEffectiveDevDependencyValue(c.Component.Id).Should().BeTrue(), "All should be development dependencies"); } [TestMethod] @@ -329,6 +329,7 @@ public async Task ScanDirectoryAsync_PackageDownload_VerificationAsync() var dependencies = componentRecorder.GetDetectedComponents(); dependencies.Should().HaveCount(3, "PackageDownload dependencies should exist."); + dependencies.Should().AllSatisfy(c => componentRecorder.GetEffectiveDevDependencyValue(c.Component.Id).Should().BeTrue(), "All PackageDownloads should be development dependencies"); dependencies.Select(c => c.Component).Should().AllBeOfType(); dependencies.Select(c => c.TargetFrameworks).Should().AllSatisfy(tfms => tfms.Should().BeEquivalentTo(["net8.0"])); }