using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Threading.Tasks;
using Supabase;
using Library;

namespace UnitTests
{
    [TestClass]
    public class GenderTests
    {
        private readonly IGenderService _genderService;

        public GenderTests()
        {
            var url = "https://eykhnnlgofgxdzlixydt.supabase.co";
            var key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImV5a2hubmxnb2ZneGR6bGl4eWR0Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjkyMzQ4NzgsImV4cCI6MjA0NDgxMDg3OH0.gG_nBmJ1KjC3se3HHNoBJLN8UA-aTw7JJw9PIMwJoL0";

            // Создаем экземпляр SupabaseClientFactory и GenderService
            var factory = new SupabaseClientFactory(url, key);
            var client = factory.CreateClient();
            _genderService = new GenderService(client);
        }

        [TestMethod]
        public async Task GetAllGendersAsync_ReturnsGenders_WhenDataExists()
        {
            var genders = await _genderService.GetAllGendersAsync();

            Assert.IsNotNull(genders);
            Assert.AreEqual(2, genders.Count);
            Assert.AreEqual(genders[0].Title, "Женский");
            Assert.AreEqual(genders[1].Title, "Мужской");
        }
    }
}
