Files
ersatztv/ErsatzTV.Tests/StartupSpaHostingTests.cs
T
2026-07-02 07:37:00 +02:00

46 lines
1.3 KiB
C#

using NUnit.Framework;
using Shouldly;
namespace ErsatzTV.Tests;
[TestFixture]
public class StartupSpaHostingTests
{
private static readonly string StartupSource = File.ReadAllText(FindStartupPath());
[Test]
public void Startup_Should_Mount_ChicoryTv_Spa_At_App_Path()
{
StartupSource.ShouldContain("ctx.Request.Path.StartsWithSegments(\"/app\")");
StartupSource.ShouldContain("MapWhen(");
StartupSource.ShouldContain("SpaStaticFileRoot");
StartupSource.ShouldContain("RequestPath = \"/app\"");
StartupSource.ShouldContain("appIndexFile");
}
[Test]
public void Startup_Should_Not_Send_App_Routes_To_Blazor_Fallback()
{
StartupSource.ShouldContain("!IsSpaPath(ctx.Request.Path)");
StartupSource.ShouldContain("bool IsSpaPath(PathString path)");
}
private static string FindStartupPath()
{
DirectoryInfo? directory = new(TestContext.CurrentContext.TestDirectory);
while (directory is not null)
{
string candidate = Path.Combine(directory.FullName, "ErsatzTV", "Startup.cs");
if (File.Exists(candidate))
{
return candidate;
}
directory = directory.Parent;
}
throw new FileNotFoundException("Could not find ErsatzTV/Startup.cs");
}
}