Skip to content

Commit df146e6

Browse files
committed
do some truth table tests
1 parent 8d97cd8 commit df146e6

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/Tests/Microsoft.NET.Build.Containers.IntegrationTests/TargetsTests.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,56 @@ public void TrimmedAppsWithCulturesGetExtraImages(string rid, string expectedIma
362362
computedBaseImageTag.Should().BeEquivalentTo(expectedImage);
363363
}
364364

365+
[InlineData("linux-musl-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine")]
366+
[InlineData("linux-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled")]
367+
[Theory]
368+
public void TrimmedAppsWithoutCulturesGetbaseImages(string rid, string expectedImage)
369+
{
370+
var (project, logger, d) = ProjectInitializer.InitProject(new()
371+
{
372+
["NetCoreSdkVersion"] = "8.0.100",
373+
["TargetFrameworkVersion"] = "v8.0",
374+
[KnownStrings.Properties.ContainerRuntimeIdentifier] = rid,
375+
[KnownStrings.Properties.PublishSelfContained] = true.ToString(),
376+
[KnownStrings.Properties.PublishTrimmed] = true.ToString(),
377+
[KnownStrings.Properties.InvariantGlobalization] = true.ToString()
378+
}, projectName: $"{nameof(TrimmedAppsWithCulturesGetExtraImages)}_{rid}_{expectedImage}");
379+
using var _ = d;
380+
var instance = project.CreateProjectInstance(global::Microsoft.Build.Execution.ProjectInstanceSettings.None);
381+
instance.Build(new[] { ComputeContainerBaseImage }, null, null, out var outputs).Should().BeTrue(String.Join(Environment.NewLine, logger.Errors));
382+
var computedBaseImageTag = instance.GetProperty(ContainerBaseImage)?.EvaluatedValue;
383+
computedBaseImageTag.Should().BeEquivalentTo(expectedImage);
384+
}
385+
386+
[InlineData(true, false, "linux-musl-x64", true, "mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine")]
387+
[InlineData(true, false, "linux-musl-x64", false, "mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine-extra")]
388+
[InlineData(false, true, "linux-musl-x64", true, "mcr.microsoft.com/dotnet/nightly/runtime-deps:8.0-alpine-aot")]
389+
[InlineData(false, true, "linux-musl-x64", false, "mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine-extra")]
390+
391+
[InlineData(true, false, "linux-x64", true, "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled")]
392+
[InlineData(true, false, "linux-x64", false, "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled-extra")]
393+
[InlineData(false, true, "linux-x64", true, "mcr.microsoft.com/dotnet/nightly/runtime-deps:8.0-jammy-chiseled-aot")]
394+
[InlineData(false, true, "linux-x64", false, "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled-extra")]
395+
[Theory]
396+
public void TheBigMatrixOfTrimmingInference(bool trimmed, bool aot, string rid, bool invariant, string expectedImage)
397+
{
398+
var (project, logger, d) = ProjectInitializer.InitProject(new()
399+
{
400+
["NetCoreSdkVersion"] = "8.0.100",
401+
["TargetFrameworkVersion"] = "v8.0",
402+
[KnownStrings.Properties.ContainerRuntimeIdentifier] = rid,
403+
[KnownStrings.Properties.PublishSelfContained] = true.ToString(),
404+
[KnownStrings.Properties.PublishTrimmed] = trimmed.ToString(),
405+
[KnownStrings.Properties.PublishAot] = aot.ToString(),
406+
[KnownStrings.Properties.InvariantGlobalization] = invariant.ToString()
407+
}, projectName: $"{nameof(TrimmedAppsWithCulturesGetExtraImages)}_{rid}_{expectedImage}");
408+
using var _ = d;
409+
var instance = project.CreateProjectInstance(global::Microsoft.Build.Execution.ProjectInstanceSettings.None);
410+
instance.Build(new[] { ComputeContainerBaseImage }, null, null, out var outputs).Should().BeTrue(String.Join(Environment.NewLine, logger.Errors));
411+
var computedBaseImageTag = instance.GetProperty(ContainerBaseImage)?.EvaluatedValue;
412+
computedBaseImageTag.Should().BeEquivalentTo(expectedImage);
413+
}
414+
365415
[InlineData("linux-musl-x64", "mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine")]
366416
[InlineData("linux-x64", "mcr.microsoft.com/dotnet/runtime-deps:7.0")]
367417
[Theory]

0 commit comments

Comments
 (0)