using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using PolyTrader.Core.Persistence;
using PolyTraderSharp.Models;

namespace PolyTrader.Tests.Fakes
{
    /// <summary>In-Memory-Stub für den generischen Core-Trade-Log (Dual-Write-Ziel der Module).</summary>
    public sealed class FakeCoreTradeLogRepository : ITradeLogRepository
    {
        public List<TradeRecord> Inserted { get; } = new();

        public void EnsureIndexes() { }
        public void Insert(TradeRecord record) => Inserted.Add(record);
        public List<TradeRecord> GetRecent(int limit) => Inserted.TakeLast(limit).ToList();
        public List<TradeRecord> Find(Expression<Func<TradeRecord, bool>> predicate) => Inserted.Where(predicate.Compile()).ToList();
    }
}
