-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
test/Microsoft.ComponentDetection.Detectors.Tests/ComponentDetectorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
namespace Microsoft.ComponentDetection.Detectors.Tests; | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using Microsoft.ComponentDetection.Contracts; | ||
using Microsoft.ComponentDetection.Orchestrator.Extensions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
[TestCategory("Governance/All")] | ||
[TestCategory("Governance/ComponentDetection")] | ||
public class ComponentDetectorTests | ||
{ | ||
private List<IComponentDetector> detectors; | ||
|
||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
var serviceProvider = new ServiceCollection().AddComponentDetection().BuildServiceProvider(); | ||
|
||
this.detectors = serviceProvider.GetServices<IComponentDetector>().ToList(); | ||
} | ||
|
||
[TestMethod] | ||
public void AllDetectorsHaveUniqueIds() | ||
{ | ||
var ids = this.detectors.Select(detector => detector.Id).ToList(); | ||
|
||
ids.Should().OnlyHaveUniqueItems(); | ||
} | ||
|
||
[TestMethod] | ||
public void AllDetectorsHavePositiveVersion() | ||
{ | ||
foreach (var detector in this.detectors) | ||
{ | ||
detector.Version.Should().BePositive($"because {detector.Id} should be > 0"); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void AllDetectorsHaveUniqueCategories() | ||
{ | ||
foreach (var detector in this.detectors) | ||
{ | ||
detector.Categories.Should().OnlyHaveUniqueItems($"because {detector.Id} should have unique categories"); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void AllDetectorsHaveUniqueSupportedComponentTypes() | ||
{ | ||
foreach (var detector in this.detectors) | ||
{ | ||
detector.SupportedComponentTypes.Should().OnlyHaveUniqueItems($"because {detector.Id} should have unique supported component types"); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ft.ComponentDetection.Detectors.Tests/Microsoft.ComponentDetection.Detectors.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters