using Dalamud.Data;
using Dalamud.Utility;
using Lumina.Excel;
namespace Dalamud.Interface.Internal.Windows.SelfTest.Steps;
///
/// Test setup for Lumina.
///
/// ExcelRow to run test on.
/// Whether or not the sheet is large. If it is large, the self test will iterate through the full sheet in one frame and benchmark the time taken.
internal class LuminaSelfTestStep(bool isLargeSheet) : ISelfTestStep
where T : struct, IExcelRow
{
private int step = 0;
private ExcelSheet rows;
///
public string Name => $"Test Lumina ({typeof(T).Name})";
///
public SelfTestStepResult RunStep()
{
this.rows ??= Service.Get().GetExcelSheet();
if (isLargeSheet)
{
var i = 0;
T currentRow = default;
foreach (var row in this.rows)
{
i++;
currentRow = row;
}
Util.ShowObject(currentRow);
return SelfTestStepResult.Pass;
}
else
{
Util.ShowObject(this.rows.GetRowAt(this.step));
this.step++;
return this.step >= this.rows.Count ? SelfTestStepResult.Pass : SelfTestStepResult.Waiting;
}
}
///
public void CleanUp()
{
this.step = 0;
}
}