public void SetLeagueStatusToInProgressAndReturnAllInProgressLeagues() { var options = new DbContextOptionsBuilder <FooteoDbContext>() .UseInMemoryDatabase(databaseName: "InProgressLeagues_Leagues_DB") .Options; var dbContext = new FooteoDbContext(options); var townsService = new TownsService(dbContext); var leaguesService = new LeaguesService(dbContext, townsService); for (int i = 1; i <= 5; i++) { leaguesService.CreateLeague($"League{i}", $"Description{i}", DateTime.UtcNow.AddDays(i), DateTime.UtcNow.AddDays(i * i), "Sofia"); } var leagues = dbContext.Leagues.ToList(); foreach (var league in leagues) { leaguesService.SetLeagueStatusToInProgress(league.Id); } var inProgressLeagues = leaguesService.AllInProgressLeagues <InProgressLeagueViewModel>().ToList(); var inProgressLeaguesCount = inProgressLeagues.Count; var expectedInProgressLeaguesCount = 5; Assert.AreEqual(expectedInProgressLeaguesCount, inProgressLeaguesCount); }
public void SetLeagueStatusShouldReturnInProgressStatus() { var options = new DbContextOptionsBuilder <FooteoDbContext>() .UseInMemoryDatabase(databaseName: "SetInProgressStatus_Leagues_DB") .Options; var dbContext = new FooteoDbContext(options); var townsService = new TownsService(dbContext); var leaguesService = new LeaguesService(dbContext, townsService); leaguesService.CreateLeague($"LeagueIP", $"Description", DateTime.UtcNow.AddDays(5), DateTime.UtcNow.AddMonths(2), "Sofia"); var league = dbContext.Leagues.FirstOrDefault(n => n.Name == "LeagueIP"); leaguesService.SetLeagueStatusToInProgress(league.Id); var expectedLeagueStatus = "InProgress"; Assert.AreEqual(expectedLeagueStatus, league.Status.ToString()); }