Namespace Nexamas.UI.Verification

    ''' <summary>
    ''' Immutable result for one baseline/current bitmap comparison.
    ''' It records exact pixel counts and the largest channel delta so failures are explainable from CI logs.
    ''' </summary>
    Friend NotInheritable Class MASRenderDiffResult

        Friend Sub New(scenario As MASRenderVerificationScenario,
                       outcome As MASRenderVerificationOutcome,
                       pixelCount As Integer,
                       differentPixelCount As Integer,
                       maxChannelDelta As Integer,
                       settings As MASRenderDiffSettings,
                       message As String)
            Me.Scenario = scenario
            Me.Outcome = outcome
            Me.PixelCount = pixelCount
            Me.DifferentPixelCount = differentPixelCount
            Me.MaxChannelDelta = maxChannelDelta
            Me.Settings = settings
            Me.Message = If(message, String.Empty)
        End Sub

        Friend ReadOnly Property Scenario As MASRenderVerificationScenario
        Friend ReadOnly Property Outcome As MASRenderVerificationOutcome
        Friend ReadOnly Property PixelCount As Integer
        Friend ReadOnly Property DifferentPixelCount As Integer
        Friend ReadOnly Property MaxChannelDelta As Integer
        Friend ReadOnly Property Settings As MASRenderDiffSettings
        Friend ReadOnly Property Message As String

        Friend ReadOnly Property DifferenceRatio As Double
            Get
                If PixelCount <= 0 Then Return 1.0R
                Return CDbl(DifferentPixelCount) / CDbl(PixelCount)
            End Get
        End Property

        Friend ReadOnly Property Passed As Boolean
            Get
                Return Outcome = MASRenderVerificationOutcome.Passed
            End Get
        End Property

        Friend ReadOnly Property RequiresApproval As Boolean
            Get
                Return Outcome = MASRenderVerificationOutcome.BaselineSeeded
            End Get
        End Property

        Friend ReadOnly Property Invalid As Boolean
            Get
                Return Outcome = MASRenderVerificationOutcome.Invalid
            End Get
        End Property

    End Class

End Namespace
