|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | +#nullable disable |
| 5 | + |
| 6 | +namespace Microsoft.NET.Sdk.Web.Tests; |
| 7 | + |
| 8 | +public class DeprecationTests(ITestOutputHelper log) : SdkTest(log) |
| 9 | +{ |
| 10 | + [Fact] |
| 11 | + public void It_does_not_show_deprecation_warning_when_IncludeOpenAPIAnalyzers_is_not_set() |
| 12 | + { |
| 13 | + var testProject = new TestProject() |
| 14 | + { |
| 15 | + Name = "WebAppWithoutOpenAPIAnalyzers", |
| 16 | + TargetFrameworks = ToolsetInfo.CurrentTargetFramework, |
| 17 | + ProjectSdk = "Microsoft.NET.Sdk.Web" |
| 18 | + }; |
| 19 | + |
| 20 | + var testAsset = _testAssetsManager.CreateTestProject(testProject); |
| 21 | + |
| 22 | + var buildCommand = new BuildCommand(testAsset); |
| 23 | + buildCommand |
| 24 | + .Execute() |
| 25 | + .Should() |
| 26 | + .Pass() |
| 27 | + .And |
| 28 | + .NotHaveStdOutContaining("ASPDEPR007") |
| 29 | + .And |
| 30 | + .NotHaveStdOutContaining("IncludeOpenAPIAnalyzers"); |
| 31 | + } |
| 32 | + |
| 33 | + [Fact] |
| 34 | + public void It_does_not_show_deprecation_warning_when_IncludeOpenAPIAnalyzers_is_false() |
| 35 | + { |
| 36 | + var testProject = new TestProject() |
| 37 | + { |
| 38 | + Name = "WebAppWithOpenAPIAnalyzersFalse", |
| 39 | + TargetFrameworks = ToolsetInfo.CurrentTargetFramework, |
| 40 | + ProjectSdk = "Microsoft.NET.Sdk.Web" |
| 41 | + }; |
| 42 | + |
| 43 | + testProject.AdditionalProperties["IncludeOpenAPIAnalyzers"] = "false"; |
| 44 | + |
| 45 | + var testAsset = _testAssetsManager.CreateTestProject(testProject); |
| 46 | + |
| 47 | + var buildCommand = new BuildCommand(testAsset); |
| 48 | + buildCommand |
| 49 | + .Execute() |
| 50 | + .Should() |
| 51 | + .Pass() |
| 52 | + .And |
| 53 | + .NotHaveStdOutContaining("ASPDEPR007"); |
| 54 | + } |
| 55 | + |
| 56 | + [Theory] |
| 57 | + [InlineData(ToolsetInfo.CurrentTargetFramework)] |
| 58 | + [InlineData("net8.0")] |
| 59 | + [InlineData("net9.0")] |
| 60 | + public void It_shows_deprecation_warning_across_target_frameworks(string targetFramework) |
| 61 | + { |
| 62 | + var testProject = new TestProject() |
| 63 | + { |
| 64 | + Name = $"WebApp_{targetFramework.Replace(".", "_")}", |
| 65 | + TargetFrameworks = targetFramework, |
| 66 | + ProjectSdk = "Microsoft.NET.Sdk.Web" |
| 67 | + }; |
| 68 | + |
| 69 | + testProject.AdditionalProperties["IncludeOpenAPIAnalyzers"] = "true"; |
| 70 | + |
| 71 | + var testAsset = _testAssetsManager.CreateTestProject(testProject, identifier: targetFramework); |
| 72 | + |
| 73 | + var buildCommand = new BuildCommand(testAsset); |
| 74 | + buildCommand |
| 75 | + .Execute() |
| 76 | + .Should() |
| 77 | + .Pass() |
| 78 | + .And |
| 79 | + .HaveStdOutContaining("ASPDEPR007"); |
| 80 | + } |
| 81 | +} |
0 commit comments