private ExchangeContext GetContextWithData() { var options = new DbContextOptionsBuilder <ExchangeContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var dbContext = new ExchangeContext(options); var share = new HourlyShareRate { Id = 1, Rate = 90, Symbol = "REL", TimeStamp = DateTime.Now }; dbContext.Add(share); dbContext.SaveChanges(); return(dbContext); }
private void Make(ExchangeContext dbContext) { var deal = new List <Order> { Buy, Sell }; Price = deal.OrderBy(o => o.Date).First().Price; Size = deal.Select(o => o.Number).Min(); foreach (Order order in deal) { order.Number -= Size; } dbContext.Add(this); dbContext.SaveChanges(); new Transaction(_dbContext).Try(); }
public async Task Test_Query_Trades() { //Arrange var trade = new Trade { Symbol = "REL", NoOfShares = 12, Price = 98.76m, PortfolioId = 1, Action = "Buy" }; //Act _testDBContext.Add(trade); await _testDBContext.SaveChangesAsync(); var result = await _tradeRepository.Query().ToListAsync(); // Assert Assert.True(result.Count > 0); }