Add EventDef notices, morning and lesson bells, and info toasts.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using HSchool.Content;
|
||||
|
||||
namespace HSchool.Content.Tests;
|
||||
|
||||
public class EventDefTests
|
||||
{
|
||||
private readonly CatalogLoader _loader = new();
|
||||
|
||||
[Fact]
|
||||
public void VanillaCore_LoadsDayAndLessonStarted()
|
||||
{
|
||||
var catalog = LoadVanilla();
|
||||
|
||||
Assert.True(catalog.Events.ContainsKey("DayStarted"));
|
||||
Assert.Equal(EventSeverities.Info, catalog.Events["DayStarted"].Severity);
|
||||
Assert.False(catalog.Events["DayStarted"].Pause);
|
||||
Assert.Equal(8000, catalog.Events["DayStarted"].TtlMs);
|
||||
Assert.Equal(EventTriggers.DayStart, catalog.Events["DayStarted"].Trigger);
|
||||
Assert.Equal(EventActions.None, catalog.Events["DayStarted"].Action);
|
||||
|
||||
Assert.True(catalog.Events.ContainsKey("LessonStarted"));
|
||||
Assert.Equal(EventSeverities.Info, catalog.Events["LessonStarted"].Severity);
|
||||
Assert.False(catalog.Events["LessonStarted"].Pause);
|
||||
Assert.Equal(8000, catalog.Events["LessonStarted"].TtlMs);
|
||||
Assert.Equal(EventTriggers.LessonStart, catalog.Events["LessonStarted"].Trigger);
|
||||
Assert.Equal(EventActions.None, catalog.Events["LessonStarted"].Action);
|
||||
|
||||
Assert.True(catalog.Events.ContainsKey("GenerationFailed"));
|
||||
Assert.Equal(EventTriggers.GenerationFailed, catalog.Events["GenerationFailed"].Trigger);
|
||||
Assert.Equal("Начало дня", catalog.Label("ru", catalog.Events["DayStarted"]));
|
||||
Assert.Equal("The day has started", catalog.Label("en", catalog.Events["DayStarted"]));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnknownTrigger_FailsTheCatalog()
|
||||
{
|
||||
var documents = PackDocuments.FromDirectory(
|
||||
CatalogLoader.CorePackId,
|
||||
Path.Combine(AppContext.BaseDirectory, "vanilla"))
|
||||
.Append(PackDocuments.Def(
|
||||
CatalogLoader.CorePackId,
|
||||
"events",
|
||||
"bad",
|
||||
"""{ "defName": "BadMoon", "severity": "info", "ttlMs": 1, "trigger": "fullMoon", "action": "none" }"""))
|
||||
.ToList();
|
||||
|
||||
var ex = Assert.Throws<ContentLoadException>(() => _loader.Load([CatalogLoader.CorePackId], documents));
|
||||
Assert.Contains("trigger", ex.Message, StringComparison.Ordinal);
|
||||
Assert.Contains("fullMoon", ex.Message, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private DefCatalog LoadVanilla()
|
||||
{
|
||||
var root = Path.Combine(AppContext.BaseDirectory, "vanilla");
|
||||
return _loader.Load([CatalogLoader.CorePackId], PackDocuments.FromDirectory(CatalogLoader.CorePackId, root));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user