Expand the typed client-command boundary across travel, character queries, local UI and layout controls, AFK and consent, emotes, friends, squelch and filters, and fill-components. Preserve retail packet layouts and queue ownership, import the confirmation dialog, and keep authoritative social state in Core. Co-Authored-By: Codex <codex@openai.com>
67 lines
2.6 KiB
C#
67 lines
2.6 KiB
C#
using AcDream.App.UI;
|
|
using AcDream.App.UI.Layout;
|
|
|
|
namespace AcDream.App.Tests.UI.Layout;
|
|
|
|
public sealed class RetailConfirmationDialogServiceTests
|
|
{
|
|
[Fact]
|
|
public void FixtureBuildsProductionConfirmationWidgets()
|
|
{
|
|
var layout = FixtureLoader.LoadConfirmationDialog();
|
|
|
|
Assert.IsType<UiDialogRoot>(layout.Root);
|
|
Assert.IsType<UiText>(layout.FindElement(RetailConfirmationDialogService.MessageElementId));
|
|
Assert.IsType<UiButton>(layout.FindElement(RetailConfirmationDialogService.AcceptButtonId));
|
|
Assert.IsType<UiButton>(layout.FindElement(RetailConfirmationDialogService.RejectButtonId));
|
|
}
|
|
|
|
[Fact]
|
|
public void ShowCentersModalAndAcceptCompletesIt()
|
|
{
|
|
var root = new UiRoot { Width = 1024f, Height = 768f };
|
|
var layout = FixtureLoader.LoadConfirmationDialog();
|
|
var service = new RetailConfirmationDialogService(root, layout);
|
|
bool? result = null;
|
|
|
|
service.Show("Do you really want to kill your character?", accepted => result = accepted);
|
|
|
|
Assert.Same(layout.Root, root.Modal);
|
|
var popup = Assert.IsAssignableFrom<UiElement>(
|
|
layout.FindElement(RetailConfirmationDialogService.PopupElementId));
|
|
Assert.Equal(MathF.Round((1024f - popup.Width) * 0.5f), popup.Left);
|
|
Assert.Equal(MathF.Round((768f - popup.Height) * 0.5f), popup.Top);
|
|
|
|
var accept = Assert.IsType<UiButton>(
|
|
layout.FindElement(RetailConfirmationDialogService.AcceptButtonId));
|
|
accept.OnClick!();
|
|
|
|
Assert.True(result);
|
|
Assert.Null(root.Modal);
|
|
Assert.False(service.IsOpen);
|
|
}
|
|
|
|
[Fact]
|
|
public void RequestsArePresentedInFifoOrder()
|
|
{
|
|
var root = new UiRoot { Width = 800f, Height = 600f };
|
|
var layout = FixtureLoader.LoadConfirmationDialog();
|
|
var service = new RetailConfirmationDialogService(root, layout);
|
|
var results = new List<string>();
|
|
|
|
service.Show("first", accepted => results.Add($"first:{accepted}"));
|
|
service.Show("second", accepted => results.Add($"second:{accepted}"));
|
|
|
|
Assert.Equal(1, service.PendingCount);
|
|
Assert.IsType<UiButton>(layout.FindElement(
|
|
RetailConfirmationDialogService.RejectButtonId)).OnClick!();
|
|
Assert.Equal(["first:False"], results);
|
|
Assert.True(service.IsOpen);
|
|
Assert.Equal(0, service.PendingCount);
|
|
|
|
Assert.IsType<UiButton>(layout.FindElement(
|
|
RetailConfirmationDialogService.AcceptButtonId)).OnClick!();
|
|
Assert.Equal(["first:False", "second:True"], results);
|
|
Assert.False(service.IsOpen);
|
|
}
|
|
}
|