using System.Collections.Generic;
using Xunit;
using QuantEngine.Core.Domain;

namespace QuantEngine.Core.Tests;

public class BacktesterTests
{
    [Fact]
    public void RunBacktest_WithValidData_ReturnsCorrectMetrics()
    {
        // Arrange
        var backtester = new Backtester();
        var dailyValues = new List<decimal> { 100m, 102m, 101m, 105m, 108m, 110m };
        var trades = new List<BacktestTrade>
        {
            new BacktestTrade("005930", System.DateTime.UtcNow.AddDays(-5), System.DateTime.UtcNow, 100m, 110m, 10, 0.10m, 1.5m)
        };

        // Act
        var result = backtester.RunBacktest("test_run_01", dailyValues, trades, 1000m);

        // Assert
        Assert.Equal("test_run_01", result.RunId);
        Assert.Equal("PASS", result.GateStatus);
        Assert.True(result.SharpeRatio > 0);
        Assert.True(result.MaxDrawdown >= 0 && result.MaxDrawdown <= 1);
        Assert.True(result.TurnoverRate > 0);
    }
}
