using Khaemhat.Web.Hosting; namespace Khaemhat.Web.Tests.Hosting; /// /// KHAEMHAT_* variables read by the host (SPEC ยง6). Command-line keys feed the same configuration as environment /// variables, so the tests pass them as arguments instead of touching the process environment. /// [TestClass] public sealed class InstanceVariablesTests { [TestMethod] public async Task LogLevel_SetsTheDefaultLevel() { await using var app = KhaemhatApp.Build(["--urls", "http://127.0.0.1:0", "--KHAEMHAT_LOG_LEVEL=warning"]); Assert.AreEqual("Warning", app.Configuration["Logging:LogLevel:Default"]); } [TestMethod] public void LogLevel_RejectsAnUnknownValue() { var error = Assert.ThrowsExactly( () => KhaemhatApp.Build(["--urls", "http://127.0.0.1:0", "--KHAEMHAT_LOG_LEVEL=loud"])); StringAssert.Contains(error.Message, "KHAEMHAT_LOG_LEVEL"); } [TestMethod] public async Task Urls_AreTakenFromTheVariable() { await using var app = KhaemhatApp.Build(["--KHAEMHAT_URLS=http://127.0.0.1:0"]); Assert.AreEqual("http://127.0.0.1:0", app.Configuration["urls"]); } }