Option Strict On
Option Explicit On

Imports System
Imports System.ComponentModel

Namespace Nexamas.UI.Verification

    ''' <summary>
    ''' Immutable release-evidence progress facts raised while MASRenderVerification creates Showcase PNG assets.
    ''' It reports real scenario completion from the runner, not a timer-simulated loading animation.
    ''' </summary>
    <EditorBrowsable(EditorBrowsableState.Advanced)>
    Public NotInheritable Class MASRenderVerificationProgressInfo

        Friend Sub New(completedScenarios As Integer,
                       totalScenarios As Integer,
                       statusText As String,
                       currentTarget As String,
                       currentScenario As String)
            Me.New(completedScenarios, totalScenarios, statusText, currentTarget, currentScenario, Double.NaN)
        End Sub

        Friend Sub New(completedScenarios As Integer,
                       totalScenarios As Integer,
                       statusText As String,
                       currentTarget As String,
                       currentScenario As String,
                       percentOverride As Double)
            Me.CompletedScenarios = Math.Max(0, completedScenarios)
            Me.TotalScenarios = Math.Max(0, totalScenarios)
            Me.StatusText = If(statusText, String.Empty)
            Me.CurrentTarget = If(currentTarget, String.Empty)
            Me.CurrentScenario = If(currentScenario, String.Empty)
            Me.PercentOverride = percentOverride
        End Sub

        Public ReadOnly Property CompletedScenarios As Integer
        Public ReadOnly Property TotalScenarios As Integer
        Public ReadOnly Property StatusText As String
        Public ReadOnly Property CurrentTarget As String
        Public ReadOnly Property CurrentScenario As String
        Public ReadOnly Property PercentOverride As Double

        Public ReadOnly Property Percent As Double
            Get
                If Not Double.IsNaN(PercentOverride) Then Return Math.Max(0.0R, Math.Min(100.0R, PercentOverride))
                If TotalScenarios <= 0 Then Return 0.0R
                Return Math.Max(0.0R, Math.Min(100.0R, (CDbl(CompletedScenarios) / CDbl(TotalScenarios)) * 100.0R))
            End Get
        End Property
    End Class

End Namespace
