Make character UI retries transactional
This commit is contained in:
parent
aeac874dab
commit
1dd5706e15
6 changed files with 352 additions and 42 deletions
|
|
@ -188,6 +188,66 @@ public sealed class CharacterManagementUiControllerTests
|
|||
Assert.Equal(3, resourceAttempts);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MountCoordinator_PostAttachFailuresDisposeBeforeRetryAndRecovery()
|
||||
{
|
||||
var host = new UiRoot { Width = 800f, Height = 600f };
|
||||
var runtime = new FakeRuntime();
|
||||
using var dialogs = new RetailDialogFactory(
|
||||
host,
|
||||
RetailDialogFactoryTests.BuildDialogLayout);
|
||||
var screens = new List<ImportedLayout>();
|
||||
int failingAttempts = 2;
|
||||
using var coordinator = new CharacterManagementUiMountCoordinator(
|
||||
host,
|
||||
runtime.Bindings,
|
||||
() => dialogs,
|
||||
() =>
|
||||
{
|
||||
ImportedLayout screen = BuildScreen();
|
||||
screens.Add(screen);
|
||||
bool throwAfterAttach = failingAttempts-- > 0;
|
||||
return new CharacterManagementUiMountResources(
|
||||
0x21000004u,
|
||||
screen,
|
||||
(_, _) => throwAfterAttach
|
||||
? throw new InvalidOperationException(
|
||||
"template failed after root attach")
|
||||
: BuildRow(),
|
||||
TestStrings());
|
||||
});
|
||||
|
||||
coordinator.Tick();
|
||||
Assert.Null(coordinator.Controller);
|
||||
Assert.Empty(host.Children);
|
||||
Assert.Single(screens);
|
||||
AssertDetachedAndUnbound(screens[0]);
|
||||
|
||||
coordinator.Tick();
|
||||
Assert.Null(coordinator.Controller);
|
||||
Assert.Empty(host.Children);
|
||||
Assert.Equal(2, screens.Count);
|
||||
Assert.All(screens, AssertDetachedAndUnbound);
|
||||
|
||||
coordinator.Tick();
|
||||
CharacterManagementUiController mounted = Assert.IsType<
|
||||
CharacterManagementUiController>(coordinator.Controller);
|
||||
Assert.Equal(3, screens.Count);
|
||||
Assert.Single(host.Children);
|
||||
Assert.Same(mounted.Root, host.Children[0]);
|
||||
Assert.NotNull(Assert.IsType<UiButton>(screens[2].FindElement(
|
||||
CharacterManagementUiController.EnterElementId)).OnClick);
|
||||
|
||||
coordinator.Tick();
|
||||
Assert.Equal(3, screens.Count);
|
||||
Assert.Single(host.Children);
|
||||
|
||||
coordinator.Dispose();
|
||||
Assert.Empty(host.Children);
|
||||
Assert.Null(coordinator.Controller);
|
||||
Assert.All(screens, AssertDetachedAndUnbound);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DeleteConfirmation_IsCaseInsensitive_ThenWaitsThroughAckUntilFreshRoster()
|
||||
{
|
||||
|
|
@ -509,6 +569,17 @@ public sealed class CharacterManagementUiControllerTests
|
|||
"Please Wait",
|
||||
"Entering World");
|
||||
|
||||
private static void AssertDetachedAndUnbound(ImportedLayout screen)
|
||||
{
|
||||
Assert.Null(screen.Root.Parent);
|
||||
Assert.Null(Assert.IsType<UiButton>(screen.FindElement(
|
||||
CharacterManagementUiController.EnterElementId)).OnClick);
|
||||
Assert.Null(Assert.IsType<UiButton>(screen.FindElement(
|
||||
CharacterManagementUiController.DeleteElementId)).OnClick);
|
||||
Assert.Null(Assert.IsType<UiButton>(screen.FindElement(
|
||||
CharacterManagementUiController.RestoreElementId)).OnClick);
|
||||
}
|
||||
|
||||
private static ImportedLayout BuildScreen(bool includePreview = false)
|
||||
{
|
||||
var root = new ElementInfo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue