コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
        }