Retry a failed portrait from the notice with the same scene builder.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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 _));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user