Imports System.Collections.Generic
Imports System.Linq

Namespace Nexamas.UI.Verification

    ''' <summary>
    ''' Readiness report produced before screenshot capture starts.
    ''' It verifies that targets, scenarios, and baseline folders form a coherent render-verification contract.
    ''' </summary>
    Friend NotInheritable Class MASRenderVerificationReport

        Private ReadOnly _findings As IReadOnlyList(Of MASRenderVerificationFinding)

        Friend Sub New(targetCount As Integer, scenarioCount As Integer, findings As IEnumerable(Of MASRenderVerificationFinding))
            Me.TargetCount = targetCount
            Me.ScenarioCount = scenarioCount
            If findings Is Nothing Then
                _findings = Array.Empty(Of MASRenderVerificationFinding)()
            Else
                _findings = findings.Where(Function(finding) finding IsNot Nothing).ToArray()
            End If
        End Sub

        Friend ReadOnly Property TargetCount As Integer
        Friend ReadOnly Property ScenarioCount As Integer

        Friend ReadOnly Property Findings As IReadOnlyList(Of MASRenderVerificationFinding)
            Get
                Return _findings
            End Get
        End Property

        Friend ReadOnly Property ErrorCount As Integer
            Get
                Return System.Linq.Enumerable.Count(_findings, Function(finding) finding.Severity = MASRenderVerificationFindingSeverity.Error)
            End Get
        End Property

        Friend ReadOnly Property IsReady As Boolean
            Get
                Return ErrorCount = 0 AndAlso TargetCount > 0 AndAlso ScenarioCount > 0
            End Get
        End Property

    End Class

End Namespace
