Skip UseFileServer when wwwroot is missing.

Local Aspire has no published client folder; the middleware warned on every boot.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-20 13:22:28 +03:00
co-authored by Cursor
parent 782a56eefe
commit e35b8e438c
5 changed files with 81 additions and 1 deletions
@@ -0,0 +1,28 @@
namespace HSchool.Server.Tests;
public class ClientStaticFilesTests
{
[Fact]
public void CanServe_IsFalseWhenTheDirectoryIsMissing()
{
var missing = Path.Combine(Path.GetTempPath(), "h-school-no-wwwroot-" + Guid.NewGuid().ToString("N"));
Assert.False(ClientStaticFiles.CanServe(missing));
Assert.False(ClientStaticFiles.CanServe(null));
Assert.False(ClientStaticFiles.CanServe(""));
}
[Fact]
public void CanServe_IsTrueWhenTheDirectoryExists()
{
var directory = Directory.CreateTempSubdirectory("h-school-wwwroot-");
try
{
Assert.True(ClientStaticFiles.CanServe(directory.FullName));
}
finally
{
directory.Delete(recursive: true);
}
}
}