using CartWise.Application.DTOs;
using CartWise.Application.Interfaces;

namespace CartWise.Application.Tests;

internal sealed class FakeProductDataProvider : IProductDataProvider
{
    private readonly Dictionary<string, ProductLookupResult> _byBarcode;

    public FakeProductDataProvider(Dictionary<string, ProductLookupResult> byBarcode, string name = "OpenFoodFacts")
    {
        _byBarcode = byBarcode;
        Name = name;
    }

    public string Name { get; }

    public Task<ProductLookupResult?> FindByBarcodeAsync(string barcode, CancellationToken cancellationToken = default)
    {
        return Task.FromResult(_byBarcode.GetValueOrDefault(barcode));
    }

    public Task<IReadOnlyList<ProductSearchResult>> SearchAsync(string query, CancellationToken cancellationToken = default)
    {
        return Task.FromResult<IReadOnlyList<ProductSearchResult>>([]);
    }
}
