Skip to content

Commit 78f0187

Browse files
authored
Cherry pick 27542
#27542
1 parent 890f746 commit 78f0187

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/Tests/Microsoft.NET.Sdk.Razor.Tests/AspNetSdkBaselineTest.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,35 @@ internal void AssertManifest(
356356
.Should()
357357
.BeEquivalentTo(expected.ReferencedProjectsConfiguration.OrderBy(cm => cm.Identity));
358358
manifest.DiscoveryPatterns.OrderBy(dp => dp.Name).ShouldBeEquivalentTo(expected.DiscoveryPatterns.OrderBy(dp => dp.Name));
359-
manifest.Assets.OrderBy(a => a.BasePath).ThenBy(a => a.RelativePath).ThenBy(a => a.AssetKind)
360-
.ShouldBeEquivalentTo(expected.Assets.OrderBy(a => a.BasePath).ThenBy(a => a.RelativePath).ThenBy(a => a.AssetKind));
359+
var manifestAssets = manifest.Assets.OrderBy(a => a.BasePath).ThenBy(a => a.RelativePath).ThenBy(a => a.AssetKind);
360+
var expectedAssets = expected.Assets.OrderBy(a => a.BasePath).ThenBy(a => a.RelativePath).ThenBy(a => a.AssetKind);
361+
362+
manifestAssets.ShouldBeEquivalentTo(expectedAssets, AssetDifferencesDetails(manifestAssets, expectedAssets));
363+
364+
static string AssetDifferencesDetails(IEnumerable<StaticWebAsset> manifestAssets, IEnumerable<StaticWebAsset> expectedAssets)
365+
{
366+
var missingAssets = expectedAssets.Except(manifestAssets);
367+
var unexpectedAssets = manifestAssets.Except(expectedAssets);
368+
369+
var differences = new List<string>();
370+
371+
if (missingAssets.Any())
372+
{
373+
differences.Add($"The following expected assets weren't found in the manifest {string.Join(", ", missingAssets.Select(a => a.Identity))}.");
374+
}
375+
376+
if (unexpectedAssets.Any())
377+
{
378+
differences.Add($"The following additional unexpected assets were found in the manifest {string.Join(", ", unexpectedAssets.Select(a => a.Identity))}.");
379+
}
380+
381+
if (differences.Any())
382+
{
383+
differences.Add("If the difference in baselines is expected, please re-generate the baselines using the src/RazorSdk/update-test-baselines.ps1 script.");
384+
}
385+
386+
return string.Join(Environment.NewLine, differences);
387+
}
361388
}
362389
else
363390
{

0 commit comments

Comments
 (0)