public async Task ExternalDataIsSupplementedWithLocalDataWhenObservationsAreMissing() { DateTime startDate = new DateTime(2000, 1, 1); DateTime endDate = new DateTime(2000, 1, 3); var inst = new Instrument { ID = 1, Symbol = "SPY", AssetCategory = AssetClass.Stock, QDMSInstrumentID = 2 }; var data = new List <OHLCBar> { new OHLCBar { Open = 1, High = 2, Low = 0, Close = 1, DT = new DateTime(2000, 1, 1) }, new OHLCBar { Open = 1, High = 2, Low = 0, Close = 1, DT = new DateTime(2000, 1, 2) }, }; _dbContext.PriorPositions.Add(new PriorPosition() { Instrument = inst, InstrumentID = inst.ID, Date = endDate, Price = 5 }); _dbContext.SaveChanges(); _externalSourceMock.Setup( x => x.GetData(It.IsAny <Instrument>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <BarSize>())) .ReturnsAsync(data); var resultData = await _datasourcer.GetData(inst, startDate, endDate); Assert.That(resultData.Count == 3); }
private void NextBtn_Click(object sender, RoutedEventArgs e) { string accountId = AccountIdTextBox.Text; if (String.IsNullOrEmpty(accountId)) { MessageBox.Show("Cannot use an empty account."); return; } using (var context = new QpasDbContext()) { //check if this account exists, otherwise add it Account account; if (context.Accounts.Any(x => x.AccountId == accountId)) { account = context.Accounts.First(x => x.AccountId == accountId); } else { account = new Account { AccountId = accountId }; context.Accounts.Add(account); context.SaveChanges(); } //Now that we have the account, set it everywhere foreach (EquitySummary es in context.EquitySummaries) { es.Account = account; } foreach (DividendAccrual da in context.DividendAccruals) { da.Account = account; } foreach (Order o in context.Orders) { o.Account = account; } foreach (Execution ex in context.Executions) { ex.Account = account; } foreach (FXTransaction fxt in context.FXTransactions) { fxt.Account = account; } foreach (FXPosition fxp in context.FXPositions) { fxp.Account = account; } foreach (CashTransaction ct in context.CashTransactions) { ct.Account = account; } foreach (OpenPosition op in context.OpenPositions) { op.Account = account; } foreach (PriorPosition pp in context.PriorPositions) { pp.Account = account; } context.SaveChanges(); } _appliedChanges = true; MessageBox.Show("Success!"); Close(); }