Thing, room, yard and climate precipitation can contribute a short prompt when they are in frame, with a budget so chairs stay silent. Co-authored-by: Cursor <cursoragent@cursor.com>
79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
using HSchool.Content;
|
|
|
|
namespace HSchool.Content.Tests;
|
|
|
|
public class ScenePromptDefTests
|
|
{
|
|
private readonly CatalogLoader _loader = new();
|
|
|
|
[Fact]
|
|
public void VanillaCore_BlackboardHasPositive_ChairIsSilent()
|
|
{
|
|
var catalog = LoadVanilla();
|
|
|
|
var blackboard = catalog.Things["Blackboard"].Prompt;
|
|
Assert.NotNull(blackboard);
|
|
Assert.False(blackboard.IsSilent);
|
|
Assert.Contains("blackboard", blackboard.Positive, StringComparison.OrdinalIgnoreCase);
|
|
|
|
var chair = catalog.Things["Chair"].Prompt;
|
|
Assert.True(chair is null || chair.IsSilent);
|
|
|
|
var classroom = catalog.Rooms["Classroom"].Prompt;
|
|
Assert.NotNull(classroom);
|
|
Assert.False(classroom.IsSilent);
|
|
|
|
var snow = catalog.ClimatePresets["TemperateContinental"].Prompt?.Snow;
|
|
Assert.NotNull(snow);
|
|
Assert.False(snow.IsSilent);
|
|
var clear = catalog.ClimatePresets["TemperateContinental"].Prompt?.Clear;
|
|
Assert.True(clear is null || clear.IsSilent);
|
|
}
|
|
|
|
[Fact]
|
|
public void PromptLongerThan120_FailsTheCatalog()
|
|
{
|
|
var documents = PackDocuments.FromDirectory(
|
|
CatalogLoader.CorePackId,
|
|
Path.Combine(AppContext.BaseDirectory, "vanilla"))
|
|
.Append(PackDocuments.Def(
|
|
CatalogLoader.CorePackId,
|
|
"things",
|
|
"long-board",
|
|
$$"""
|
|
{
|
|
"defName": "LongBoard",
|
|
"prompt": { "positive": "{{new string('x', 121)}}" }
|
|
}
|
|
"""))
|
|
.ToList();
|
|
|
|
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load([CatalogLoader.CorePackId], documents));
|
|
Assert.Contains("120", ex.Message, StringComparison.Ordinal);
|
|
Assert.Contains("LongBoard", ex.Message, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void NegativePromptWeight_FailsTheCatalog()
|
|
{
|
|
var documents = PackDocuments.FromDirectory(
|
|
CatalogLoader.CorePackId,
|
|
Path.Combine(AppContext.BaseDirectory, "vanilla"))
|
|
.Append(PackDocuments.Def(
|
|
CatalogLoader.CorePackId,
|
|
"things",
|
|
"bad-weight",
|
|
"""{ "defName": "BadWeight", "prompt": { "positive": "ok", "weight": -0.1 } }"""))
|
|
.ToList();
|
|
|
|
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load([CatalogLoader.CorePackId], documents));
|
|
Assert.Contains("weight", ex.Message, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
private DefCatalog LoadVanilla()
|
|
{
|
|
var root = Path.Combine(AppContext.BaseDirectory, "vanilla");
|
|
return _loader.Load([CatalogLoader.CorePackId], PackDocuments.FromDirectory(CatalogLoader.CorePackId, root));
|
|
}
|
|
}
|