public void SubmitOffer() { Trader me = null; TradingPost post = null; Commodity commondity = null; NewTradeOffer offer = null; int id = 0; var dbName = "SubmitOffer"; "Given I am a trader".x(async() => { var traderRepository = new TraderRepository(CreateNewContext(dbName)); id = await traderRepository.New(TestTradeDataStatic.MargamanTrader); me = await traderRepository.Get(id); }); "And I have a trading post".x(async() => { var systemRepository = new AstralSystemRepository(CreateNewContext(dbName)); await systemRepository.New(TestSystemDataStatic.StantonSystem); var system = await systemRepository.Get(id); post = system.TradePoints.OfType <TradingPost>().First(); }); "And I have a new commodity".x(async() => { var commodityRepo = new CommodityRepository(CreateNewContext(dbName)); var id = await commodityRepo.New(TestTradeDataStatic.AgriciumCommondity); commondity = await commodityRepo.Get(id); }); "And I have an offer".x(() => offer = new NewTradeOffer { Id = 0, TraderId = me.Id, TradePointId = post.Id, CommodityId = commondity.Id, PricePerUnit = 23.99M, OfferType = (int)OfferType.Buy }); "When I submit the offer".x(async() => { var traderRepository = new TraderRepository(CreateNewContext(dbName)); var command = new NewTradeOfferCommand(traderRepository); id = await command.Execute(offer); }); "Then the Offer is displayed".x(async() => { var traderRepository = new TraderRepository(CreateNewContext(dbName), true); var trader = await traderRepository.Get(me.Id); AssertOffer(trader.TradeOffers.First(o => o.Id == id), offer); }); }
public void SubmitTrader() { Trader trader = null; int id = 0; var dbName = "SubmitTrader"; "Given I have a new trader".x(() => trader = TestTradeDataStatic.MargamanTrader); "When I submit the trader".x(async() => { var traderRepository = new TraderRepository(CreateNewContext(dbName)); await traderRepository.New(trader); id = trader.Id; }); "Then the trader is displayed".x(async() => { var traderRepository = new TraderRepository(CreateNewContext(dbName)); AssertTrader(await traderRepository.Get(id), trader); }); }
/// <summary> /// 根据Id获取模型 /// </summary> public TraderInfo GetModelById(int id) { return(_traderRepository.Get(id)); }