using Microsoft.Extensions.Logging.Abstractions; using VegetableShop.API.Services; using VegetableShop.Domain.Model; using VegetableShop.Infrastructure.Persistence; using Xunit; namespace VegetableShop.API.IntegrationTests { public class ConsumersServicesTests { private readonly ConsumerServices _consumerServices; private readonly ConsumerRepositoryImpl _consumerRepository; private readonly FarmerRepositoryImpl _farmerRepository; private readonly VegetableRepositoryImpl _vegetableRepository; private readonly Context _context; public ConsumersServicesTests() { var loggerFactory = new NullLoggerFactory(); _context = new Context(loggerFactory); _consumerRepository = new ConsumerRepositoryImpl(_context); _farmerRepository = new FarmerRepositoryImpl(_context); _vegetableRepository = new VegetableRepositoryImpl(_context); _consumerServices = new ConsumerServices(loggerFactory, _consumerRepository, _farmerRepository, _vegetableRepository); // Initialize test data _context.Consumers.Add(1L, new Consumer(loggerFactory)); _context.Farmers.Add(1L, new Farmer(loggerFactory)); _context.Vegetables.Add(1L, new Vegetable("carrot")); } [Fact] public void ShouldBuyVegetables() { _consumerServices.BuyVegetables(1L, 1L, 1L, 10); } } }