public CurrencyObjectsRepositoryTests() { var options = new DbContextOptionsBuilder <CurrencyDbContext>().UseInMemoryDatabase("TestDb").Options; db = new CurrencyDbContext(options); repository = new CurrencyObjectsRepository(db); }
/// <summary> /// Reset database /// </summary> /// <returns></returns> public async Task ResetDatabase() { var builder = new DbContextOptionsBuilder <CurrencyDbContext>(); builder.UseSqlServer(ConnectionStringHelper.GetDefaultConfigurationBuild().GetDefaultConnectionString()); using (var context = new CurrencyDbContext(builder.Options)) { var startDate = _holidayChecker.ReturnDateBeforeDayOff(CurrencyCollectionModel.StartDate); foreach (var currencyCode in CurrencyCollectionModel.CurrencyCodes) { if (string.IsNullOrWhiteSpace(currencyCode.Key) || string.IsNullOrWhiteSpace(currencyCode.Value)) { continue; } var itemsToRemove = context.CurrencyValues.Include(c => c.Currency).Where( c => c.Currency.CurrencyBeingMeasured.ToLower() == currencyCode.Key.ToLower() && c.Currency.CurrencyMatched.ToLower() == currencyCode.Value.ToLower() && (c.DailyDataOfCurrency >= startDate && c.DailyDataOfCurrency <= CurrencyCollectionModel.EndDate)); context.CurrencyValues.RemoveRange(itemsToRemove); await context.SaveChangesAsync(); } } }
public void SetUp() { var options = new DbContextOptionsBuilder <CurrencyDbContext>() .UseInMemoryDatabase(databaseName: "CurrencyListDatabase") .ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning)) .Options; _dbContext = new CurrencyDbContext(options); _holidayCheckerMock = new Mock <IHolidayChecker>(); _cacheDatabase = new CacheDatabase(_dbContext, _holidayCheckerMock.Object); }
public SqlCurrencyRepository(string connString) { this.context = new CurrencyDbContext(connString); }
/// <summary> /// Creates instance of class /// </summary> /// <param name="dbContext"><see cref="CurrencyDbContext"/></param> /// <param name="holidayChecker"><see cref="IHolidayChecker"/></param> public CacheDatabase(CurrencyDbContext dbContext, IHolidayChecker holidayChecker) { _dbContext = dbContext; _holidayChecker = holidayChecker; }
public CurrencyRatesQueryService(ICurrencyRatesBetweenDatesReceiver currencyRatesBetweenDatesReceiver, CurrencyDbContext currencyDbContext) { _currencyRatesBetweenDatesReceiver = currencyRatesBetweenDatesReceiver; _currencyDbContext = currencyDbContext; }
public CurrencyRateRepository(CurrencyDbContext context) { _dbContext = context; }
public HomeController(CountryDbContext coContext, CurrencyDbContext cuContext) { countryContext = coContext; currencyContext = cuContext; }
public CurrencyRatesCommandService(CurrencyDbContext currencyDbContext) { _currencyDbContext = currencyDbContext; }