Option Strict On
Option Explicit On

Namespace Nexamas.UI.Components

    ''' <summary>
    ''' Friend-only proof that MASAppLayout can snapshot and restore its owned visual
    ''' slot labels/text and visibility choices without claiming routing, PageHost,
    ''' child-host, native shell, or external storage ownership.
    ''' </summary>
    Friend NotInheritable Class MASAppLayoutPersistenceGate
        Private Sub New()
        End Sub

        Friend Shared Function Passes() As Boolean
            Try
                If Not MASAppLayoutPolicy.HasLayoutSnapshotPersistencePath() Then Return False

                Dim layout As MASAppLayout = MASAppLayout.Create("Gate app")
                layout.SetNavigation("Nav", "Navigation content")
                layout.SetContent("Content", "Main content")
                layout.SetDetails("Details", "Detail content")
                layout.StatusText = "Ready"
                layout.ShowNavigation = False
                layout.ShowDetails = True
                layout.ShowStatusBar = False

                Dim snapshot As MASAppLayoutSnapshot = layout.CreateLayoutSnapshot()
                If snapshot Is Nothing Then Return False
                If snapshot.Title <> "Gate app" Then Return False
                If snapshot.NavigationTitle <> "Nav" Then Return False
                If snapshot.ShowNavigation Then Return False
                If Not snapshot.ShowDetails Then Return False
                If snapshot.ShowStatusBar Then Return False

                layout.ResetLayoutSlots()
                If layout.ShowNavigation = False OrElse layout.ShowStatusBar = False Then Return False
                If Not layout.RestoreLayoutSnapshot(snapshot) Then Return False
                If layout.NavigationTitle <> "Nav" Then Return False
                If layout.ContentTitle <> "Content" Then Return False
                If layout.DetailTitle <> "Details" Then Return False
                If layout.ShowNavigation Then Return False
                If Not layout.ShowDetails Then Return False
                If layout.ShowStatusBar Then Return False
                If Not layout.HasLayoutSnapshotForTests() Then Return False

                Return True
            Catch ex As System.Exception
                Nexamas.UI.Diagnostics.MASExceptionSilencer.SwallowDiagnosticOnly(ex, "MASAppLayoutPersistenceGate")
                Return False
            End Try
        End Function
    End Class

End Namespace
