from pathlib import Path
import sys

ROOT = Path(__file__).resolve().parents[2]
checks = {
    'factory group': ('MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Containers.vb', 'Public Function AddGroupBox(Optional title As String = Nothing,'),
    'factory expander': ('MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Containers.vb', 'Public Function AddExpander(Optional title As String = Nothing,'),
    'factory accordion': ('MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Containers.vb', 'Public Function AddAccordion(Optional allowMultipleExpanded As Boolean = False,'),
    'factory tile': ('MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Containers.vb', 'Public Function AddTileBox(Optional configure As Action(Of MASTileBox) = Nothing) As MASTileBox'),
    'group acrylic default': ('Component/Container/GroupBox/MASGroupBox.vb', 'Private _surfaceSource As MASGroupBoxSurfaceSource = MASGroupBoxSurfaceSource.Acrylic'),
    'group border default': ('Component/Container/GroupBox/MASGroupBox.vb', 'Private _borderStrength As MASGroupBoxBorderStrength = MASGroupBoxBorderStrength.Level5'),
    'group shadow default': ('Component/Container/GroupBox/MASGroupBox.vb', 'Private _drawShadow As Boolean = True'),
    'group separator default': ('Component/Container/GroupBox/MASGroupBox.vb', 'Private _drawSeparator As Boolean = False'),
    'expander expanded default': ('Component/Container/Expander/MASExpander.vb', 'Private _isExpanded As Boolean = True'),
    'expander event': ('Component/Container/Expander/MASExpander.vb', 'Public Event ExpandedChanged As EventHandler'),
    'accordion multiple default': ('Component/Container/Accordion/MASAccordion.vb', 'Public Shared Function Create(Optional allowMultipleExpanded As Boolean = False) As MASAccordion'),
    'accordion invalid index': ('Component/Container/Accordion/MASAccordion.vb', 'Throw New ArgumentOutOfRangeException(NameOf(index))'),
    'tile events': ('Component/Surfaces/Tiles/MASTileBox.vb', 'Public Event ItemClicked As EventHandler(Of MASTileClickedEventArgs)'),
    'tile invalid index clears': ('Component/Surfaces/Tiles/MASTileBox.Selection.vb', 'If value < 0 OrElse value >= _items.Count Then'),
    'tile replace clears without event': ('Component/Surfaces/Tiles/MASTileBox.Items.vb', 'SetSelectionInternal(Guid.Empty, Nothing, raiseChanged:=False, invalidate:=False)'),
    'doc linked': ('docs/reference/api/README.md', '[Containers and tile surfaces — source-verified reference](../controls/containers-and-tiles.md)'),
}
failed=[]
for name,(rel,needle) in checks.items():
    text=(ROOT/rel).read_text(encoding='utf-8-sig')
    if needle not in text:
        failed.append(f'{name}: {rel}: {needle}')
if failed:
    print('FAILED')
    print('\n'.join(failed))
    sys.exit(1)
print(f'Assertions: {len(checks)} passed, 0 failed')
