Files
git.stella-ops.org/src/Scanner/__Tests/StellaOps.Scanner.Analyzers.Lang.Tests/DotNet/DotNetEntrypointResolverTests.cs
2026-01-08 08:54:27 +02:00

53 lines
2.3 KiB
C#

using System.Linq;
using Xunit;
using System.Threading;
using System.Threading.Tasks;
using StellaOps.Scanner.Analyzers.Lang;
using StellaOps.Scanner.Analyzers.Lang.DotNet.Internal;
using StellaOps.Scanner.Analyzers.Lang.Tests.TestUtilities;
namespace StellaOps.Scanner.Analyzers.Lang.Tests.DotNet;
public sealed class DotNetEntrypointResolverTests
{
[Fact]
public async Task SimpleFixtureResolvesSingleEntrypointAsync()
{
var cancellationToken = TestContext.Current.CancellationToken;
var fixturePath = TestPaths.ResolveFixture("lang", "dotnet", "simple");
var context = new LanguageAnalyzerContext(fixturePath, TimeProvider.System);
var entrypoints = await DotNetEntrypointResolver.ResolveAsync(context, cancellationToken);
Assert.Single(entrypoints);
var entrypoint = entrypoints[0];
Assert.Equal("Sample.App", entrypoint.Name);
Assert.Equal("Sample.App:Microsoft.AspNetCore.App@10.0.0+Microsoft.NETCore.App@10.0.0+net10.0:any+linux+linux-x64+unix+win+win-x86:frameworkdependent:no-mvid", entrypoint.Id);
Assert.Contains("net10.0", entrypoint.TargetFrameworks);
Assert.Contains("linux-x64", entrypoint.RuntimeIdentifiers);
Assert.Equal("Sample.App.deps.json", entrypoint.RelativeDepsPath);
Assert.Equal("Sample.App.runtimeconfig.json", entrypoint.RelativeRuntimeConfigPath);
Assert.Equal(DotNetPublishKind.FrameworkDependent, entrypoint.PublishKind);
}
[Fact]
public async Task DeterministicOrderingIsStableAsync()
{
var cancellationToken = TestContext.Current.CancellationToken;
var fixturePath = TestPaths.ResolveFixture("lang", "dotnet", "multi");
var context = new LanguageAnalyzerContext(fixturePath, TimeProvider.System);
var first = await DotNetEntrypointResolver.ResolveAsync(context, cancellationToken);
var second = await DotNetEntrypointResolver.ResolveAsync(context, cancellationToken);
Assert.Equal(first.Count, second.Count);
for (var i = 0; i < first.Count; i++)
{
Assert.Equal(first[i].Id, second[i].Id);
Assert.True(first[i].TargetFrameworks.SequenceEqual(second[i].TargetFrameworks));
Assert.True(first[i].RuntimeIdentifiers.SequenceEqual(second[i].RuntimeIdentifiers));
}
}
}