public void SetUp() { var builder = new ConfigurationBuilder(). SetBasePath(Directory.GetCurrentDirectory()). AddJsonFile("appsettings.json"); Configuration = builder.Build(); var serviceCollection = new ServiceCollection(); serviceCollection.AddDbContext <ProductContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ProductContext"))); serviceCollection.AddScoped <ICalculateProductPrice, CalculateProductPrice>(); serviceCollection.AddScoped <IReceiptService, ReceiptService>(); serviceCollection.AddScoped <IRegisterService, RegisterService>(); serviceCollection.AddScoped <IProductService, ProductService>(); serviceCollection.AddScoped <ISupplyService, SupplyService>(); serviceCollection.AddScoped <IMapperService, MapperService>(); var serviceProvider = serviceCollection.BuildServiceProvider(); CalculateProductPrice = serviceProvider.GetService <ICalculateProductPrice>(); ReceiptService = serviceProvider.GetService <IReceiptService>(); RegisterService = serviceProvider.GetService <IRegisterService>(); ProductService = serviceProvider.GetService <IProductService>(); SupplyService = serviceProvider.GetService <ISupplyService>(); }
public void SetUp() { _calculateProductPrice = new CalculateProductPrice(); }
public MapperService(ICalculateProductPrice calculateProductPrice) { _calculateProductPrice = calculateProductPrice; }