from pathlib import Path
import json, sys
root=Path(__file__).resolve().parents[2]
checks=[]
def contains(path,text,label):
    data=(root/path).read_text(encoding='utf-8-sig')
    checks.append((label,text in data))
contains(Path('MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Containers.vb'),'Public Function AddLabel(Optional text As String = Nothing','AddLabel route')
contains(Path('MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Containers.vb'),'Public Function AddTitle(text As String,','AddTitle route')
contains(Path('MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Feedback.vb'),'Public Function AddBadge(Optional text As String = Nothing,','AddBadge route')
contains(Path('MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Feedback.vb'),'Public Function AddAvatar(Optional displayName As String = Nothing,','AddAvatar route')
contains(Path('MASSystem/Application/Facade/MASApplicationWindowControls.ControlFactory.Feedback.vb'),'Public Function AddAvatarGroup(Optional avatars As IEnumerable(Of MASAvatar) = Nothing,','AddAvatarGroup route')
contains(Path('Component/Feedback/Label/MASLabel.vb'),'Private _labelVariant As MASLabelVariant = MASLabelVariant.Body','label variant default')
contains(Path('Component/Feedback/Label/MASLabel.vb'),'Private _multiLine As Boolean = False','label multiline default')
contains(Path('Component/Feedback/Label/MASLabel.vb'),'Private _wordWrap As Boolean = True','label wrap default')
contains(Path('Component/Feedback/Label/MASLabel.vb'),'_textStyle = MASLabelTypographyPolicy.ResolveTextStyleFromVariant(nextValue)','variant resolves text style')
contains(Path('Component/Feedback/Label/MASLabel.vb'),'_hasTextColor = False','ClearTextColor override removal')
contains(Path('Component/Reusable/TitleSeparator/MASTitle.vb'),'Private _drawDivider As Boolean = True','title divider default')
contains(Path('Component/Feedback/Badge/MASBadge.vb'),'Private _tone As MASToastTone = MASToastTone.Neutral','badge tone default')
contains(Path('Component/Feedback/Badge/MASBadge.vb'),'Private _dotOnly As Boolean','badge dot default false')
contains(Path('Component/Feedback/Avatar/MASAvatar.vb'),'avatar._accentColor = MASAvatarIdentityPolicy.ResolveDeterministicAccent','deterministic avatar accent')
contains(Path('Component/Feedback/Avatar/MASAvatar.vb'),'_usesDeterministicAccent = False','explicit accent disables deterministic updates')
contains(Path('Component/Feedback/Avatar/MASAvatar.vb'),'RaiseSelectedChangedSafe()','avatar selected event')
contains(Path('Component/Feedback/Avatar/MASAvatarGroup.vb'),'Private _selectedIndex As Integer = -1','group selection default')
contains(Path('Component/Feedback/Avatar/MASAvatarGroup.vb'),'If avatar Is Nothing Then Return Me','group ignores null avatar')
contains(Path('Component/Feedback/Avatar/MASAvatarGroup.vb'),'If index < 0 OrElse index >= _avatars.Count Then Return Nothing','GetAvatar invalid index')
contains(Path('Component/Feedback/Avatar/MASAvatarGroup.vb'),'If _avatars.Count = 0 Then Return Me','empty clear no-op')
contains(Path('Component/Feedback/Avatar/MASAvatarGroup.vb'),'If disposing Then CloseOverflowSafe()','group disposal closes overflow')
base=json.loads((root/'eng/tests/Nexamas.UI.PublicApiClassificationBaseline.json').read_text(encoding='utf-8-sig'))
classes={x['name']:x['category'] for x in base['classifications']}
for name,cat in [('MASLabel','Stable'),('MASTitle','Stable'),('MASBadge','Stable'),('MASAvatar','Advanced'),('MASAvatarGroup','Advanced')]:
    checks.append((f'{name} {cat} classification',classes.get(name)==cat))
doc=(root/'docs/reference/controls/text-identity-and-badges.md').read_text(encoding='utf-8')
for phrase in ['Explicit custom initials are therefore preserved','does not dispose each avatar','`DrawDivider` defaults to `True`','`LabelVariant` also resolves and replaces `TextStyle`']:
    checks.append((f'document claim: {phrase}',phrase in doc))
failed=[name for name,ok in checks if not ok]
for name,ok in checks: print(('PASS' if ok else 'FAIL')+': '+name)
print(f'Assertions: {len(checks)-len(failed)} passed, {len(failed)} failed')
sys.exit(1 if failed else 0)
