public async Task ShouldFindSingleRouteMatch() { const string routeTag = "20"; var agency = new Agency { Tag = "TTC", }; var route = new AgencyRoute { Agency = agency, Tag = routeTag, }; var route2 = new AgencyRoute { Agency = agency, Tag = routeTag + "a", }; string[] results; using (BusVbotDbContext dbContext = DbContextProvider.CreateInMemoryDbContext(nameof(ShouldFindSingleRouteMatch))) { dbContext.AddRange(route, route2); dbContext.SaveChanges(); IAgencyDataParser sut = new TtcDataParser(dbContext); results = await sut.FindMatchingRoutesAsync(routeTag); } Assert.Single(results); Assert.Equal(routeTag, results[0]); }
public DataSeeder(BusVbotDbContext dbContext, INextBusClient nextBusClient, ILogger <DataSeeder> logger) { _nextBusClient = nextBusClient; _logger = logger; _dbContext = dbContext; }
protected AgencyDataParserBase( BusVbotDbContext dbContext, string agencyTag = null, string sampleRoutesMarkdown = null ) { DbContext = dbContext; AgencyTag = agencyTag; SampleRoutesMarkdownText = sampleRoutesMarkdown ?? Constants.SampleRoutesText; }
public PredictionsManager( INextBusClient nextBusClient, ICachingService cachingService, ILocationsManager locationsManager, BusVbotDbContext dbContext, IAgencyServiceAccessor agencyServiceAccessor ) { _nextBusClient = nextBusClient; _cachingService = cachingService; _locationsManager = locationsManager; _dbContext = dbContext; _agencyServiceAccessor = agencyServiceAccessor; }
internal static BusVbotDbContext CreateInMemoryDbContext(string dbName = "", bool deleteIfExists = true) { var options = new DbContextOptionsBuilder <BusVbotDbContext>() .UseInMemoryDatabase(dbName) .Options; var dbContext = new BusVbotDbContext(options); if (deleteIfExists) { dbContext.Database.EnsureDeleted(); dbContext.Database.EnsureCreated(); } return(dbContext); }
public async Task ShouldFindAllDirectionsForRoute(string routeTag, string[] directions, string directionText) { #region SeedData var agency = new Agency { Tag = "TTC", Routes = new List <AgencyRoute>(), }; var route = new AgencyRoute { Agency = agency, Tag = routeTag, Directions = directions.Select(dTag => new RouteDirection { Tag = dTag.ToUpper(), Name = dTag.ToUpper(), }).ToList(), }; agency.Routes.Add(route); #endregion string[] results; using (BusVbotDbContext dbContext = DbContextProvider.CreateInMemoryDbContext(nameof(ShouldFindAllDirectionsForRoute))) { dbContext.Add(agency); dbContext.SaveChanges(); IAgencyDataParser sut = new TtcDataParser(dbContext); results = await sut.FindMatchingDirectionsForRouteAsync(routeTag, directionText); } Assert.Equal(directions.Length, results.Length); foreach (var result in results) { Assert.Contains(result, directions, StringComparer.OrdinalIgnoreCase); } }
public CachingService(IMemoryCache cache, BusVbotDbContext dbContext) { _cache = cache; _dbContext = dbContext; }
public DefaultAgencyDataParser(BusVbotDbContext dbContext) : base(dbContext) { }
public UserContextManager(BusVbotDbContext dbContext, IMemoryCache cache) { _dbContext = dbContext; _cache = cache; }
public TtcDataParser(BusVbotDbContext dbContext) : base(dbContext, Constants.Tag, Constants.SampleRoutesText) { }