Files
duempelkas/tests/Duempelkas.Tests/DesktopResourceTests.cs
T

30 lines
1.3 KiB
C#

using System.Text.RegularExpressions;
using Xunit;
namespace Duempelkas.Tests;
public class DesktopResourceTests
{
[Fact]
public void StartupStylesAndFonts_AreDeliveredLocally()
{
var root = new DirectoryInfo(AppContext.BaseDirectory);
while (root != null && !File.Exists(Path.Combine(root.FullName, "src", "Duempelkas.Desktop", "Duempelkas.Desktop.csproj"))) root = root.Parent;
Assert.NotNull(root);
var web = Path.Combine(root.FullName, "src", "Duempelkas.Desktop", "wwwroot");
var html = File.ReadAllText(Path.Combine(web, "index.html"));
Assert.DoesNotContain("https://", html);
foreach (Match match in Regex.Matches(html, "(?:href|src)=\"([^\"]+)\""))
{
var path = match.Groups[1].Value;
if (path.Length == 0 || path == "/" || path.StartsWith("_framework")) continue;
Assert.True(File.Exists(Path.Combine(web, path)), path);
}
var icons = Path.Combine(web, "vendor", "bootstrap-icons");
var css = File.ReadAllText(Path.Combine(icons, "bootstrap-icons.min.css"));
foreach (Match match in Regex.Matches(css, "url\\([\"']?([^\"')]+)"))
Assert.True(File.Exists(Path.Combine(icons, match.Groups[1].Value.Split('?')[0])));
Assert.True(File.Exists(Path.Combine(icons, "LICENSE")));
}
}