public ClearSaleServiceTest() { //--- mock _clearSaleProxyMock = new Mock <IClearSaleProxy> (); _configurationDataMongoRepositoryMock = new Mock <IConfigurationDataMongoRepository> (); _configurationDataSqlRepositoryMock = new Mock <IConfigurationDataSqlRepository> (); _configurationDataCacheServiceMock = new Mock <IConfigurationDataCacheService> (); _userSqlRepositoryMock = new Mock <IUserSqlRepository> (); //--- configuração do DI _serviceCollection = new ServiceCollection(); _serviceCollection.AddMemoryCache(); _serviceCollection.AddSingleton <IClearSaleProxy> (_clearSaleProxyMock.Object); _serviceCollection.AddSingleton <IConfigurationDataMongoRepository> (_configurationDataMongoRepositoryMock.Object); _serviceCollection.AddSingleton <IConfigurationDataSqlRepository> (_configurationDataSqlRepositoryMock.Object); _serviceCollection.AddSingleton <IConfigurationDataCacheService> (_configurationDataCacheServiceMock.Object); _serviceCollection.AddSingleton <IClearSaleService, ClearSaleService> (); _serviceCollection.AddSingleton <IUserSqlRepository> (_userSqlRepositoryMock.Object); //--- obter o service var services = _serviceCollection.BuildServiceProvider(); _clearSaleService = services.GetService <IClearSaleService> (); // Dados Fake _faker = new Faker(); _name = _faker.Person.FirstName; _email = _faker.Person.Email; _randomInt = _faker.Random.Int(0, int.MaxValue); }
public AntifraudProcessor(ISaleProcessor saleProcessor, IClearSaleService clearSaleService, ITransactionCreator transactionCreator, ApplicationDbContext dbContext) { SaleProcessor = saleProcessor ?? throw new ArgumentNullException(nameof(saleProcessor)); ClearSaleService = clearSaleService ?? throw new ArgumentNullException(nameof(clearSaleService)); TransactionCreator = transactionCreator ?? throw new ArgumentNullException(nameof(transactionCreator)); DbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); }
/// <summary> /// Injeção de dependencia para o serviço do clearsale /// </summary> public ClearSaleController(IClearSaleService clearSaleService) { _clearSaleService = clearSaleService; }