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 des Entscheidungsjournals – Tests können Journal-Einträge asserten.</summary>
    public sealed class FakeDecisionJournal : IDecisionJournal
    {
        public List<DecisionRecord> Written { get; } = new();
        public void Write(DecisionRecord record) => Written.Add(record);
        public List<DecisionRecord> Query(Expression<Func<DecisionRecord, bool>> predicate, int limit = 1000)
            => Written.Where(predicate.Compile()).Take(limit).ToList();
    }

    /// <summary>In-Memory-Stub des Order-Lifecycle-Logs.</summary>
    public sealed class FakeOrderEventLog : IOrderEventLog
    {
        public List<OrderEventRecord> Written { get; } = new();
        public void Write(OrderEventRecord record) => Written.Add(record);
        public List<OrderEventRecord> Query(Expression<Func<OrderEventRecord, bool>> predicate, int limit = 1000)
            => Written.Where(predicate.Compile()).Take(limit).ToList();
    }
}
