public void GetBestTradeFromLocation() { AstralSystem system = null; Planet location = null; List <TradeOption> results = null; var dbName = "GetBestTradeFromLocation"; "Given I have a system with historical trades".x(async() => system = await GenerateSystem(CreateNewContext(dbName))); "And I have a search Location".x(() => location = system.Planets.First(p => p.Name == "ArcCorp")); "When I ask for the best trade".x(async() => { var tradeAnalyser = new SimpleLogicTradeAnalyser(new TraderRepository(CreateNewContext(dbName), true), new AstralSystemRepository(CreateNewContext(dbName), true)); results = (await tradeAnalyser.GetBestNearPlanet(5, location.Id, DateTime.Parse("15/03/2020"))).ToList(); }); "Then I am returned the top 5 trades".x(() => results.Count.Should().Be(expectedTrades)); }
public void SubmitSystem() { AstralSystem system = null; int id = 0; string dbName = "SubmitSystem"; "Given I have a new system".x(() => system = TestSystemDataStatic.StantonSystem); "When I Submit the system".x(async() => { var systemRepository = new AstralSystemRepository(CreateNewContext(dbName)); await systemRepository.New(TestSystemDataStatic.StantonSystem); id = TestSystemDataStatic.StantonSystem.Id; }); "Then the system is displayed".x(async() => { var systemRepository = new AstralSystemRepository(CreateNewContext(dbName)); AssertSystem(await systemRepository.Get(id), TestSystemDataStatic.StantonSystem); }); }
private static IDictionary <string, List <TradeOffer> > GetTradesFromTestDataCsv(IEnumerable <Commodity> commodities, AstralSystem system) { var tradePoints = system.TradePoints.ToList(); var buyRecords = File.ReadAllLines(@"./TestData/SCTradePrices - Buy.csv").Select(l => l.Split(',')); var sellRecords = File.ReadAllLines(@"./TestData/SCTradePrices - Sell.csv").Select(l => l.Split(',')); var groupByTradePointName = buyRecords.Union(sellRecords).GroupBy(r => r[0]); var tradesByLocation = groupByTradePointName.ToDictionary(g => g.Key, g => g.Select(r => { return(GetTradeFromRecord(r, tradePoints, commodities)); }).ToList()); return(tradesByLocation); }
private void AssertSystem(AstralSystem actual, AstralSystem expected) { actual.Id.Should().BeGreaterThan(0); actual.Name.Should().Be(expected.Name); }