using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using LittleShop.Client.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using TeleBot.Services;

namespace TeleBot
{
    /// <summary>
    /// Simple test class to verify carousel functionality
    /// This can be used for testing the ProductCarouselService
    /// </summary>
    public class TestCarousel
    {
        public static async Task TestImageValidation()
        {
            var config = new ConfigurationBuilder().Build();
            var logger = NullLogger<ProductCarouselService>.Instance;
            var httpClient = new System.Net.Http.HttpClient();
            
            var carouselService = new ProductCarouselService(config, logger, httpClient);
            
            // Test image URL validation
            var validUrls = new[]
            {
                "https://via.placeholder.com/300x200.jpg",
                "https://picsum.photos/300/200",
                "https://httpbin.org/image/jpeg"
            };
            
            foreach (var url in validUrls)
            {
                var isValid = await carouselService.IsImageUrlValidAsync(url);
                Console.WriteLine($"URL {url} is valid: {isValid}");
            }
        }
        
        public static async Task TestProductImage()
        {
            var config = new ConfigurationBuilder().Build();
            var logger = NullLogger<ProductCarouselService>.Instance;
            var httpClient = new System.Net.Http.HttpClient();
            
            var carouselService = new ProductCarouselService(config, logger, httpClient);
            
            // Create a test product with image
            var testProduct = new Product
            {
                Id = Guid.NewGuid(),
                Name = "Test Product",
                Price = 29.99m,
                Description = "A test product for carousel functionality",
                Photos = new List<ProductPhoto>
                {
                    new ProductPhoto
                    {
                        Id = Guid.NewGuid(),
                        Url = "https://via.placeholder.com/300x200.jpg",
                        IsMain = true
                    }
                }
            };
            
            // Test getting product image
            var image = await carouselService.GetProductImageAsync(testProduct);
            Console.WriteLine($"Product image retrieved: {image != null}");
        }
    }
}
