public ManageSeasonControllerTests() { LeagueDbInstance db = new LeagueDbInstance(); _testContext = db.NewContext(); _verifyContext = db.NewContext(); SingleInstanceFactory factory = request => new CreateSeasonCommandHandler(_testContext); _mediator = new Mediator(factory, null); }
public void CanAddGolfer() { using var dbInstance = new LeagueDbInstance(nameof(CanAddGolfer)); using (var leagueData = dbInstance.NewContext()) { leagueData.Golfers.Add(new Golfer()); leagueData.SaveChanges(); } using (var leagueData = dbInstance.NewContext()) { Equal(1, leagueData.Golfers.Count()); } }
public void CanSaveSeasonGraph() { using var dbInstance = new LeagueDbInstance(nameof(CanSaveSeasonGraph)); var data = new LeagueData(dbInstance.NewContext()); var season = new Season() { Name = nameof(CanSaveSeasonGraph) }; var golferA = new Golfer { Id = 1, LeagueHandicap = 8 }; var golferB = new Golfer { Id = 3, LeagueHandicap = 2 }; var golferC = new Golfer { Id = 5, LeagueHandicap = 2 }; var golferD = new Golfer { Id = 7, LeagueHandicap = 2 }; var week1 = new MatchSet(DateTime.Now); season.AddWeek(week1); week1.AddResult(golferA, 44, 7, true, golferB, 36, 4, false); week1.AddResult(golferC, 44, 7, true, golferD, 36, 4, false); var week2 = new MatchSet(DateTime.Now); season.AddWeek(week2); week2.AddResult(golferA, 44, 7, true, golferD, 36, 4, false); week2.AddResult(golferB, 44, 7, true, golferC, 36, 4, false); data.Add(season, golferA, golferB, golferC, golferD); data.Commit(); var checkData = new LeagueData(dbInstance.NewContext()); var query = new SeasonDetailQuery(season.Id); var checkSeason = checkData.Execute(query); Assert.Equal(2, checkSeason.Weeks.Count); Assert.Equal(2, checkSeason.Weeks.First().Matches.Count); }
public IdentityTests() { _db = new LeagueDbInstance(nameof(IdentityTests)); _passwordManager = new PasswordManager(); _context = new HttpContextWithAuthentication(); _logger = new LoggerFactory().CreateLogger <SignInManager>(); _signInManager = new SignInManager(_db.NewContext(), _passwordManager, _context, _logger); SetupDatabaseState(); }
public void CanSaveAndRetrieveSeason() { using var dbInstance = new LeagueDbInstance(nameof(CanSaveAndRetrieveSeason)); var seasonName = nameof(CanSaveAndRetrieveSeason); var data = new LeagueData(dbInstance.NewContext()); var season = new Season() { Name = seasonName }; data.Add(season); data.Commit(); var secondData = new LeagueData(dbInstance.NewContext()); var query = new SeasonDetailQuery(season.Id); var secondSeason = secondData.Execute(query); Assert.Equal(season.Id, secondSeason.Id); Assert.Equal(season.Name, secondSeason.Name); }
public AllGolfersQueryTests() { Db = new LeagueDbInstance(nameof(AllGolfersQueryTests)); var context = Db.NewContext(); context.Golfers.AddRange( new Golfer { Id = 1, FirstName = "A", IsActive = true }, new Golfer { Id = 2, FirstName = "A", IsActive = true }, new Golfer { Id = 3, FirstName = "B", IsActive = false }, new Golfer { Id = 4, FirstName = "C", IsCardMatch = true } ); context.SaveChanges(); }