/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/ProjectTemplates/test/Templates.Tests/EmptyWebTemplateTest.cs
140 строк
5 KB
Damian Edwards
Add replaceRepeatedHyphens step to template processing and update tests for DNS-compliant hostnames (#65027)
13 янв 2026, 21:58
Не верифицирован
13 янв 2026, 21:58
98fbe05
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Text.Json; using System.Threading.Tasks; using Microsoft.AspNetCore.InternalTesting; using Templates.Test.Helpers; using Xunit; using Xunit.Abstractions; namespace Templates.Test; #pragma warning disable xUnit1041 // Fixture arguments to test classes must have fixture sources public class EmptyWebTemplateTest : LoggedTest { public EmptyWebTemplateTest(ProjectFactoryFixture projectFactory) { ProjectFactory = projectFactory; } public ProjectFactoryFixture ProjectFactory { get; } private ITestOutputHelper _output; public ITestOutputHelper Output { get { if (_output == null) { _output = new TestOutputLogger(Logger); } return _output; } } [ConditionalFact] [SkipOnHelix("Cert failure, https://github.com/dotnet/aspnetcore/issues/28090", Queues = "All.OSX;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)] public async Task EmptyWebTemplateCSharp() { await EmtpyTemplateCore(languageOverride: null); } [ConditionalFact] [SkipOnHelix("Cert failure, https://github.com/dotnet/aspnetcore/issues/28090", Queues = "All.OSX;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)] public async Task EmptyWebTemplateNoHttpsCSharp() { await EmtpyTemplateCore(languageOverride: null, args: new[] { ArgConstants.NoHttps }); } [ConditionalFact] [SkipOnHelix("Cert failure, https://github.com/dotnet/aspnetcore/issues/28090", Queues = "All.OSX;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)] public async Task EmptyWebTemplateProgramMainCSharp() { await EmtpyTemplateCore(languageOverride: null, args: new[] { ArgConstants.UseProgramMain }); } [ConditionalFact] [SkipOnHelix("Cert failure, https://github.com/dotnet/aspnetcore/issues/28090", Queues = "All.OSX;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)] public async Task EmptyWebTemplateProgramMainNoHttpsCSharp() { await EmtpyTemplateCore(languageOverride: null, args: new[] { ArgConstants.UseProgramMain, ArgConstants.NoHttps }); } [Fact] public async Task EmptyWebTemplateFSharp() { await EmtpyTemplateCore("F#"); } [Fact] public async Task EmptyWebTemplateNoHttpsFSharp() { await EmtpyTemplateCore("F#", args: new[] { ArgConstants.NoHttps }); } [ConditionalTheory] [InlineData("my.namespace.web", "my-namespace-web")] [InlineData(".StartWithDot", "startwithdot")] [InlineData("EndWithDot.", "endwithdot")] [InlineData("My..Test__Project", "my-test-project")] [InlineData("Project123.Test456", "project123-test456")] [InlineData("xn--My.Test.Project", "xn-my-test-project")] [SkipOnHelix("Cert failure, https://github.com/dotnet/aspnetcore/issues/28090", Queues = "All.OSX;" + HelixConstants.Windows10Arm64 + HelixConstants.DebianArm64)] public async Task EmptyWebTemplateLocalhostTld_GeneratesDnsCompliantHostnames(string projectName, string expectedHostname) { var project = await ProjectFactory.CreateProject(Output, projectName); await project.RunDotNetNewAsync("web", args: new[] { ArgConstants.LocalhostTld }); var expectedLaunchProfileNames = new[] { "http", "https" }; await project.VerifyLaunchSettings(expectedLaunchProfileNames); await project.VerifyDnsCompliantHostname(expectedHostname); } private async Task EmtpyTemplateCore(string languageOverride, string[] args = null) { var project = await ProjectFactory.CreateProject(Output); await project.RunDotNetNewAsync("web", args: args, language: languageOverride); var noHttps = args?.Contains(ArgConstants.NoHttps) ?? false; var expectedLaunchProfileNames = noHttps ? new[] { "http" } : new[] { "http", "https" }; await project.VerifyLaunchSettings(expectedLaunchProfileNames); // Avoid the F# compiler. See https://github.com/dotnet/aspnetcore/issues/14022 if (languageOverride != null) { return; } await project.RunDotNetPublishAsync(); // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build // later, while the opposite is not true. await project.RunDotNetBuildAsync(); using (var aspNetProcess = project.StartBuiltProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); await aspNetProcess.AssertOk("/"); } using (var aspNetProcess = project.StartPublishedProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process)); await aspNetProcess.AssertOk("/"); } } }