public void Execute_WithSportFilter_Succeeds() { string dbName = "ExecuteTeamsQuery_WithSportFilter_Succeeds"; // Create dependency injection provider using method as database name var serviceProvider = BuildServiceProvider(dbName); var options = GetContextOptions(dbName); // Retrieve service to be tested var serviceToTest = serviceProvider.GetService <IQueryService <Team, TeamQueryFilterOptions> >(); // Seed data required for test SeedService.SeedCodeValues(options); var nfl = LeagueCodeService.NFL; var nhl = LeagueCodeService.NHL; SeedService.SeedTeam(options, "SanFrancisco49ers", "San Francisco", "49ers", nfl.Identifier, true); SeedService.SeedTeam(options, "SanJoseSharks", "San Jose", "Sharks", nhl.Identifier, false); SeedService.SeedTeam(options, "LosAngelesChargers", "Los Angeles", "Chargers", nfl.Identifier, false); int expectedFootballTeamCount = 2; var teamQueryFilterOptions = new TeamQueryFilterOptions { SportId = SportCodeService.Football.Id }; // Run the test var teamList = serviceToTest.Execute(teamQueryFilterOptions); // Verify results match expected results Assert.Equal(expectedFootballTeamCount, teamList.Count); }
public void Execute_WithNotableFilter_Succeeds() { string dbName = "ExecuteTeamsQuery_WithNotableFilter_Succeeds"; // Create dependency injection provider using method as database name var serviceProvider = BuildServiceProvider(dbName); var options = GetContextOptions(dbName); // Retrieve service to be tested var serviceToTest = serviceProvider.GetService <IQueryService <Team, TeamQueryFilterOptions> >(); // Seed data required for test SeedService.SeedCodeValues(options); SeedService.SeedTeam(options, "SanFrancisco49ers", "San Francisco", "49ers", "NFL", true); // only one notable team SeedService.SeedTeam(options, "SanJoseSharks", "San Jose", "Sharks", "NHL", false); SeedService.SeedTeam(options, "LosAngelesChargers", "Los Angeles", "Chargers", "NFL", false); int expectedNotableTeamCount = 1; var teamQueryFilterOptions = new TeamQueryFilterOptions { NotableFlag = true }; // Run the test var teamList = serviceToTest.Execute(teamQueryFilterOptions); // Verify results match expected results Assert.Equal(expectedNotableTeamCount, teamList.Count); }
public static TeamQueryFilterOptions BuildTeamFilterOptions(TeamSearchFilterOptions filterOptions) { var teamFilterOptions = new TeamQueryFilterOptions { LeagueId = filterOptions.LeagueId, NotableFlag = filterOptions.NotableFlag, SportId = filterOptions.SportId }; return(teamFilterOptions); }