Retry a failed portrait from the notice with the same scene builder.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-21 01:48:30 +03:00
co-authored by Cursor
parent 3c70227229
commit 3061e09d3e
32 changed files with 712 additions and 105 deletions
@@ -0,0 +1,43 @@
using HSchool.Server.Game;
namespace HSchool.Server.Tests;
public class GenerationFailedPosterTests
{
[Fact]
public void SwarmFailure_ShouldPost_SuccessAndNotConfiguredShouldNot()
{
Assert.True(GenerationFailedPoster.ShouldPost(PortraitGenerationOutcome.Unavailable));
Assert.True(GenerationFailedPoster.ShouldPost(PortraitGenerationOutcome.TimedOut));
Assert.False(GenerationFailedPoster.ShouldPost(PortraitGenerationOutcome.Succeeded));
Assert.False(GenerationFailedPoster.ShouldPost(PortraitGenerationOutcome.NotConfigured));
Assert.False(GenerationFailedPoster.ShouldPost(PortraitGenerationOutcome.InvalidPrompt));
Assert.False(GenerationFailedPoster.ShouldPost(PortraitGenerationOutcome.UnknownPerson));
}
[Fact]
public async Task TryEnqueue_WithPerson_PostsGenerationFailed()
{
var queue = new GameCommandQueue();
GenerationFailedPoster.TryEnqueue(queue, schoolId: 4, personId: "a0.p0", PortraitKind.Avatar);
var command = await queue.Reader.ReadAsync(TestContext.Current.CancellationToken);
var post = Assert.IsType<GameCommand.PostSchoolNotice>(command);
Assert.Equal(4, post.SchoolId);
Assert.Equal(GenerationFailedPoster.DefName, post.DefName);
Assert.Equal("a0.p0", post.PersonKey);
Assert.Equal("avatar", post.Kind);
}
[Fact]
public void TryEnqueue_WithoutPerson_DoesNotPost()
{
var queue = new GameCommandQueue();
GenerationFailedPoster.TryEnqueue(queue, schoolId: 4, personId: "", PortraitKind.Full);
GenerationFailedPoster.TryEnqueue(queue, schoolId: 4, personId: " ", PortraitKind.Full);
Assert.False(queue.Reader.TryRead(out _));
}
}