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 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); } }
[InlineData(43.6568934f, -79.435741f, 2)] // Dufferin Mall public async Task Should_Find_Multiple_Agencies_For_Location(float lat, float lon, int agencyMatches) { var agency1 = new Agency { Tag = "ttc", MaxLatitude = 43.90953, MinLatitude = 43.5918099, MinLongitude = -79.6499, MaxLongitude = -79.12305, }; var agency2 = new Agency { Tag = "other-agency", MaxLatitude = 43.90953, MinLatitude = 43.6479442, MinLongitude = -79.6499, MaxLongitude = -79.4015097, }; var location = new Location { Latitude = lat, Longitude = lon }; Agency[] agencies; using (var dbContext = DbContextProvider.CreateInMemoryDbContext(nameof(Should_Find_Multiple_Agencies_For_Location))) { dbContext.AddRange(agency1, agency2); dbContext.SaveChanges(); // ILocationsManager sut = new LocationsManager(null, dbContext); // agencies = await sut.FindAgenciesForLocationAsync(location); } // Assert.Equal(agencyMatches, agencies.Length); }