using AcDream.App.Spells; using AcDream.App.UI; using AcDream.App.UI.Layout; using AcDream.Core.Items; using AcDream.Core.Spells; namespace AcDream.App.Tests.UI.Layout; public sealed class SpellbookWindowControllerTests { [Fact] public void RetailFixture_BindsTextTabs_AndPropagatesOpenClosedState() { ImportedLayout layout = FixtureLoader.LoadSpellbook(); var closed = new List(); using SpellbookWindowController? controller = SpellbookWindowController.Bind( layout, new Spellbook(), new ClientObjectTable(), () => 1u, new Dictionary(), spellId => spellId, iconId => iconId, _ => 1, _ => { }, _ => { }, _ => { }, (_, _) => { }, () => closed.Add(1u)); Assert.NotNull(controller); UiText spellTab = Assert.IsType(layout.FindElement(SpellbookWindowController.SpellTabId)); UiText componentTab = Assert.IsType(layout.FindElement(SpellbookWindowController.ComponentTabId)); UiElement spellPage = Assert.IsAssignableFrom(layout.FindElement(SpellbookWindowController.SpellPageId)); UiElement componentPage = Assert.IsAssignableFrom(layout.FindElement(SpellbookWindowController.ComponentPageId)); Assert.Equal(RetailUiStateIds.Open, spellTab.ActiveRetailStateId); Assert.Equal(RetailUiStateIds.Closed, componentTab.ActiveRetailStateId); Assert.True(spellPage.Visible); Assert.False(componentPage.Visible); Assert.Equal(3, spellTab.Children.Count); Assert.All(spellTab.Children, child => Assert.Equal(RetailUiStateIds.Open, Assert.IsAssignableFrom(child).ActiveRetailStateId)); componentTab.OnEvent(new UiEvent(0, componentTab, UiEventType.Click)); Assert.Equal(SpellbookWindowPage.Components, controller!.CurrentPage); Assert.Equal(RetailUiStateIds.Closed, spellTab.ActiveRetailStateId); Assert.Equal(RetailUiStateIds.Open, componentTab.ActiveRetailStateId); Assert.False(spellPage.Visible); Assert.True(componentPage.Visible); Assert.All(componentTab.Children, child => Assert.Equal(RetailUiStateIds.Open, Assert.IsAssignableFrom(child).ActiveRetailStateId)); Assert.Empty(closed); } }