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 void ShouldFailDirection(string directionText) { IAgencyDataParser sut = new TtcDataParser(null); var result = sut.TryParseToDirectionName(null, directionText); Assert.False(result.Success); Assert.Null(result.DirectionName); }
public void ShouldParseDirection(string expectedDirection, string directionText) { IAgencyDataParser sut = new TtcDataParser(null); var result = sut.TryParseToDirectionName(null, directionText); Assert.True(result.Success); Assert.Equal(expectedDirection, result.DirectionName); }
public void ShouldFailInvalidRoutes(string routeText) { IAgencyDataParser sut = new TtcDataParser(null); var result = sut.TryParseToRouteTag(routeText); Assert.False(result.Success); Assert.Null(result.RouteTag); }
public void ShouldParseRouteTag(string routeText) { IAgencyDataParser sut = new TtcDataParser(null); var result = sut.TryParseToRouteTag(routeText); Assert.True(result.Success); Assert.NotEmpty(result.RouteTag); }
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); } }