Skip to content

[StaticWebAssets] Move static web assets tests into their own project #49645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@
<Project Path="test/Microsoft.NET.Sdk.Publish.Tasks.Tests/Microsoft.NET.Sdk.Publish.Tasks.Tests.csproj" />
<Project Path="test/Microsoft.NET.Sdk.Razor.Tests/Microsoft.NET.Sdk.Razor.Tests.csproj" />
<Project Path="test/Microsoft.NET.Sdk.Razor.Tool.Tests/Microsoft.NET.Sdk.Razor.Tool.Tests.csproj" />
<Project Path="test/Microsoft.NET.Sdk.StaticWebAssets.Tests/Microsoft.NET.Sdk.StaticWebAssets.Tests.csproj" />
<Project Path="test/Microsoft.NET.Sdk.Web.Tests/Microsoft.NET.Sdk.Web.Tests.csproj" />
<Project Path="test/Microsoft.NET.Sdk.WorkloadManifestReader.Tests/Microsoft.NET.Sdk.WorkloadManifestReader.Tests.csproj" />
<Project Path="test/Microsoft.NET.TestFramework/Microsoft.NET.TestFramework.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<ItemGroup>
<InternalsVisibleTo Include="Microsoft.NET.Sdk.Razor.Tests" />
<InternalsVisibleTo Include="Microsoft.NET.Sdk.StaticWebAssets.Tests" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.NET.Sdk.Razor.Tests;
using Microsoft.NET.Sdk.StaticWebAssets.Tests;

namespace Microsoft.NET.Sdk.BlazorWebAssembly.Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.AspNetCore.StaticWebAssets.Tasks;
using Microsoft.NET.Sdk.Razor.Tests;
using Microsoft.NET.Sdk.StaticWebAssets.Tests;

namespace Microsoft.NET.Sdk.BlazorWebAssembly.Tests
{
public class BlazorLegacyIntegrationTest60(ITestOutputHelper log)
: IsolatedNuGetPackageFolderAspNetSdkBaselineTest(log, nameof(BlazorLegacyIntegrationTest60))
{

protected override string EmbeddedResourcePrefix =>
protected override string EmbeddedResourcePrefix =>
string.Join('.', "Microsoft.NET.Sdk.BlazorWebAssembly.Tests", "StaticWebAssetsBaselines");

protected override string ComputeBaselineFolder() =>
Path.Combine(TestContext.GetRepoRoot() ?? AppContext.BaseDirectory, "test", "Microsoft.NET.Sdk.BlazorWebAssembly.Tests", "StaticWebAssetsBaselines");

[CoreMSBuildOnlyFact]
public void Build60Hosted_Works()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.NET.Sdk.Razor.Tests;
using Microsoft.NET.Sdk.StaticWebAssets.Tests;

namespace Microsoft.NET.Sdk.BlazorWebAssembly.Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.NET.Sdk.Razor.Tests;
using Microsoft.NET.Sdk.StaticWebAssets.Tests;

namespace Microsoft.NET.Sdk.BlazorWebAssembly.Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\Microsoft.NET.Sdk.Razor.Tests\AspNetSdkBaselineTest.cs" Link="AspNetSdkBaselineTest.cs" />
<Compile Include="..\Microsoft.NET.Sdk.Razor.Tests\IsolatedNuGetPackageFolderAspNetSdkBaselineTest.cs" Link="IsolatedNuGetPackageFolderAspNetSdkBaselineTest.cs" />
<Compile Include="..\Microsoft.NET.Sdk.Razor.Tests\StaticWebAssetsBaselineFactory.cs" Link="StaticWebAssetsBaselineFactory.cs" />
<Compile Include="..\Microsoft.NET.Sdk.Razor.Tests\StaticWebAssetsBaselineComparer.cs" Link="StaticWebAssetsBaselineComparer.cs" />
<Compile Include="..\Microsoft.NET.Sdk.StaticWebAssets.Tests\AspNetSdkBaselineTest.cs" Link="AspNetSdkBaselineTest.cs" />
<Compile Include="..\Microsoft.NET.Sdk.StaticWebAssets.Tests\IsolatedNuGetPackageFolderAspNetSdkBaselineTest.cs" Link="IsolatedNuGetPackageFolderAspNetSdkBaselineTest.cs" />
<Compile Include="..\Microsoft.NET.Sdk.StaticWebAssets.Tests\StaticWebAssetsBaselineFactory.cs" Link="StaticWebAssetsBaselineFactory.cs" />
<Compile Include="..\Microsoft.NET.Sdk.StaticWebAssets.Tests\StaticWebAssetsBaselineComparer.cs" Link="StaticWebAssetsBaselineComparer.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<_Parameter2>5.0</_Parameter2>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
Expand All @@ -55,8 +55,6 @@
<None Include="TestFiles\Generated\*.bundle.scp.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="StaticWebAssetsBaselines\**">
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions test/Microsoft.NET.Sdk.StaticWebAssets.Tests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# C# files
[*.cs]

#### Core EditorConfig Options ####

# var preferences
csharp_style_var_elsewhere = true
csharp_style_var_for_built_in_types = true
csharp_style_var_when_type_is_apparent = true

# IDE0073: The file header does not match the required text
dotnet_diagnostic.IDE0073.severity = error
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Text.Json;
using Microsoft.AspNetCore.StaticWebAssets.Tasks;

namespace Microsoft.NET.Sdk.Razor.Tests
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
{
[Trait("AspNetCore", "BaselineTest")]
public class AspNetSdkBaselineTest : AspNetSdkTest
Expand Down Expand Up @@ -68,9 +68,9 @@ public AspNetSdkBaselineTest(ITestOutputHelper log, bool generateBaselines) : th
private static StaticWebAssetsBaselineFactory CreateBaselineFactory() => StaticWebAssetsBaselineFactory.Instance;

protected virtual string ComputeBaselineFolder() =>
Path.Combine(TestContext.GetRepoRoot() ?? AppContext.BaseDirectory, "test", "Microsoft.NET.Sdk.Razor.Tests", "StaticWebAssetsBaselines");
Path.Combine(TestContext.GetRepoRoot() ?? AppContext.BaseDirectory, "test", "Microsoft.NET.Sdk.StaticWebAssets.Tests", "StaticWebAssetsBaselines");

protected virtual string EmbeddedResourcePrefix => string.Join('.', "Microsoft.NET.Sdk.Razor.Tests", "StaticWebAssetsBaselines");
protected virtual string EmbeddedResourcePrefix => string.Join('.', "Microsoft.NET.Sdk.StaticWebAssets.Tests", "StaticWebAssetsBaselines");

public StaticWebAssetsManifest LoadBuildManifest(string suffix = "", [CallerMemberName] string name = "")
{
Expand Down Expand Up @@ -324,4 +324,3 @@ private string Templatize(StaticWebAssetsManifest manifest, string projectRoot,
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Microsoft.Build.Framework;
using Moq;

namespace Microsoft.NET.Sdk.Razor.Tests;
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests;
public class ComputeStaticWebAssetsTargetPathsTest
{
[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.


namespace Microsoft.NET.Sdk.Razor.Tests
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
{
[Trait("AspNetCore", "NugetIsolation")]
[Trait("AspNetCore", "BaselineTest")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using Microsoft.AspNetCore.StaticWebAssets.Tasks;

namespace Microsoft.NET.Sdk.Razor.Tests
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
{
public class JsModulesIntegrationTest(ITestOutputHelper log) : IsolatedNuGetPackageFolderAspNetSdkBaselineTest(log, nameof(JsModulesIntegrationTest))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[assembly:CollectionBehavior(DisableTestParallelization = true)]

namespace Microsoft.NET.Sdk.Razor.Tests
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
{
public class LegacyStaticWebAssetsV1IntegrationTest(ITestOutputHelper log)
: IsolatedNuGetPackageFolderAspNetSdkBaselineTest(log, nameof(LegacyStaticWebAssetsV1IntegrationTest))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<EnableDefaultItems>false</EnableDefaultItems>
<OutDirName>Tests\$(MSBuildProjectName)</OutDirName>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>$(SdkTargetFramework)</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<PackageId>testSdkStaticWebAssets</PackageId>
</PropertyGroup>

<ItemGroup>
<Compile Include="**\*.cs" Exclude="$(GlobalExclude)" />
</ItemGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>AspNetTestTfm</_Parameter1>
<_Parameter2>$(SdkTargetFramework)</_Parameter2>
</AssemblyAttribute>
<!-- We use these to templatize the output from our build/publish tests to ensure the right set of
files gets published in all circumstances.
-->
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>NetCoreAppRuntimePackageVersion</_Parameter1>
<_Parameter2>$(MicrosoftNETCoreAppRuntimePackageVersion)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>DefaultTestBaselinePackageVersion</_Parameter1>
<_Parameter2>5.0</_Parameter2>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Moq" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\StaticWebAssetsSdk\Tasks\Microsoft.NET.Sdk.StaticWebAssets.Tasks.csproj" />
<ProjectReference Include="..\Microsoft.NET.TestFramework\Microsoft.NET.TestFramework.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="StaticWebAssetsBaselines\**">
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="content\ExternalStaticAssets.targets" />
</ItemGroup>

<ItemGroup>
<None Include="TestFiles\Generated\*.rz.scp.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="TestFiles\Generated\*.bundle.scp.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.StaticWebAssets.Tasks;

namespace Microsoft.NET.Sdk.Razor.Tests
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
{
public class ScopedCssIntegrationTest(ITestOutputHelper log)
: IsolatedNuGetPackageFolderAspNetSdkBaselineTest(log, nameof(ScopedCssIntegrationTest))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.StaticWebAssets.Tasks;

namespace Microsoft.NET.Sdk.Razor.Tests;
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests;

public partial class StaticWebAssetEndpointsIntegrationTest(ITestOutputHelper log)
: AspNetSdkBaselineTest(log, GenerateBaselines)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable
Expand All @@ -10,7 +10,7 @@
using Microsoft.Build.Utilities;
using Moq;

namespace Microsoft.NET.Sdk.Razor.Tests.StaticWebAssets;
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests.StaticWebAssets;

public class ApplyCompressionNegotiationTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Build.Utilities;
using Moq;

namespace Microsoft.NET.Sdk.Razor.Tests
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
{
public class ApplyAllCssScopesTest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable
Expand All @@ -8,7 +8,7 @@
using Microsoft.Build.Utilities;
using Moq;

namespace Microsoft.NET.Sdk.Razor.Tests;
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests;

public class ComputeEndpointsForReferenceStaticWebAssetsTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.Build.Framework;
using Moq;

namespace Microsoft.NET.Sdk.Razor.Tests
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
{
public class ComputeReferenceStaticWebAssetItemsTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Microsoft.Build.Framework;
using Moq;

namespace Microsoft.NET.Sdk.Razor.Tests
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
{
public class ComputeStaticWebAssetsForCurrentProjectTest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;
using Microsoft.AspNetCore.StaticWebAssets.Tasks;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Microsoft.NET.Sdk.Razor.Tests.StaticWebAssets;
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests.StaticWebAssets;

public class ContentTypeProviderTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable
Expand All @@ -13,7 +13,7 @@
using System.Net;
using System.Globalization;

namespace Microsoft.NET.Sdk.Razor.Tests;
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests;

public class DefineStaticWebAssetEndpointsTest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable
Expand All @@ -7,7 +7,7 @@
using Microsoft.Build.Framework;
using Moq;

namespace Microsoft.NET.Sdk.Razor.Tests;
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests;

public class DiscoverPrecompressedAssetsTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Microsoft.Build.Utilities;
using Moq;

namespace Microsoft.NET.Sdk.Razor.Tests
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
{
public class DiscoverStaticWebAssetsTest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable
Expand All @@ -8,7 +8,7 @@
using Microsoft.Build.Utilities;
using Moq;

namespace Microsoft.NET.Sdk.Razor.Tests.StaticWebAssets;
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests.StaticWebAssets;
public class FilterStaticWebAssetEndpointsTest
{
[Fact]
Expand Down
Loading