Replace the single mutable confirmation service with retail's property-backed DialogFactory model: fresh DAT roots, context ids, queue groups, priority preemption, callback/close-notice ordering, and context cancellation. Route /die, server confirmation aborts, and guarded item use through focused semantic owners. Co-Authored-By: Codex <codex@openai.com>
58 lines
2.3 KiB
C#
58 lines
2.3 KiB
C#
using AcDream.App.UI;
|
|
using AcDream.App.UI.Layout;
|
|
using AcDream.App.Tests.UI.Layout;
|
|
using AcDream.Core.Net.Messages;
|
|
|
|
namespace AcDream.App.Tests.UI;
|
|
|
|
public sealed class GameplayConfirmationControllerTests
|
|
{
|
|
[Fact]
|
|
public void SkillRequestAppendsContinueAndCloseNoticeSendsServerTuple()
|
|
{
|
|
var root = new UiRoot { Width = 800f, Height = 600f };
|
|
ImportedLayout? shown = null;
|
|
var factory = new RetailDialogFactory(root, _ =>
|
|
shown = FixtureLoader.LoadConfirmationDialog());
|
|
var responses = new List<(uint Type, uint Context, bool Accepted)>();
|
|
using var controller = new GameplayConfirmationController(
|
|
factory,
|
|
(type, context, accepted) => responses.Add((type, context, accepted)));
|
|
|
|
Assert.True(controller.HandleRequest(
|
|
new GameEvents.CharacterConfirmationRequest(2u, 42u, "Raise this skill?")));
|
|
Assert.Equal(
|
|
"Raise this skill? Continue?",
|
|
string.Join(" ", Assert.IsType<UiText>(shown!.FindElement(
|
|
RetailConfirmationDialogView.MessageElementId)).LinesProvider().Select(static line => line.Text)));
|
|
|
|
Assert.IsType<UiButton>(shown.FindElement(
|
|
RetailConfirmationDialogView.AcceptButtonId)).OnClick!();
|
|
|
|
Assert.Equal([(2u, 42u, true)], responses);
|
|
Assert.Equal(0u, controller.ActiveDialogContext);
|
|
}
|
|
|
|
[Fact]
|
|
public void MatchingConfirmationDoneClosesDialogAndUnmatchedTupleDoesNothing()
|
|
{
|
|
var root = new UiRoot { Width = 800f, Height = 600f };
|
|
var factory = new RetailDialogFactory(root, _ =>
|
|
FixtureLoader.LoadConfirmationDialog());
|
|
var responses = new List<(uint Type, uint Context, bool Accepted)>();
|
|
using var controller = new GameplayConfirmationController(
|
|
factory,
|
|
(type, context, accepted) => responses.Add((type, context, accepted)));
|
|
controller.HandleRequest(new GameEvents.CharacterConfirmationRequest(7u, 99u, "Proceed?"));
|
|
|
|
Assert.False(controller.HandleDone(
|
|
new GameEvents.CharacterConfirmationDone(7u, 100u)));
|
|
Assert.True(factory.IsOpen);
|
|
Assert.True(controller.HandleDone(
|
|
new GameEvents.CharacterConfirmationDone(7u, 99u)));
|
|
|
|
Assert.False(factory.IsOpen);
|
|
Assert.Equal([(7u, 99u, false)], responses);
|
|
}
|
|
|
|
}
|