audit, advisories and doctors/setup work
This commit is contained in:
@@ -0,0 +1 @@
|
||||
global using Xunit;
|
||||
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="xunit" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Xml.Linq;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace NugetPrime.Tests;
|
||||
|
||||
public sealed class NugetPrimeTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("nuget-prime.csproj")]
|
||||
[InlineData("nuget-prime-v9.csproj")]
|
||||
public void PackageDownloads_ArePinned(string projectFile)
|
||||
{
|
||||
var repoRoot = FindRepoRoot();
|
||||
var path = Path.Combine(repoRoot, "devops", "tools", "nuget-prime", projectFile);
|
||||
File.Exists(path).Should().BeTrue($"expected {projectFile} under devops/tools/nuget-prime");
|
||||
|
||||
var doc = XDocument.Load(path);
|
||||
var packages = doc.Descendants().Where(element => element.Name.LocalName == "PackageDownload").ToList();
|
||||
packages.Should().NotBeEmpty();
|
||||
|
||||
foreach (var package in packages)
|
||||
{
|
||||
var include = package.Attribute("Include")?.Value;
|
||||
include.Should().NotBeNullOrWhiteSpace();
|
||||
|
||||
var version = package.Attribute("Version")?.Value;
|
||||
version.Should().NotBeNullOrWhiteSpace();
|
||||
version.Should().NotContain("*");
|
||||
}
|
||||
}
|
||||
|
||||
private static string FindRepoRoot()
|
||||
{
|
||||
var current = new DirectoryInfo(AppContext.BaseDirectory);
|
||||
for (var i = 0; i < 12 && current is not null; i++)
|
||||
{
|
||||
var candidate = Path.Combine(current.FullName, "devops", "tools", "nuget-prime", "nuget-prime.csproj");
|
||||
if (File.Exists(candidate))
|
||||
{
|
||||
return current.FullName;
|
||||
}
|
||||
|
||||
current = current.Parent;
|
||||
}
|
||||
|
||||
throw new DirectoryNotFoundException("Repo root not found for devops/tools/nuget-prime");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user