public void ShouldAddDivisionToSeasonTwoLevelDivision() { var season = new Season() { Number = 1, Year = 1, Name = "First Season" }; var league = new SeasonDivision("League", null, DivisionLevel.League, null, null, null); var conference = new SeasonDivision("Conference", null, DivisionLevel.Conference, null, null, null); for (int i = 0; i < 10; i++) { conference.AddTeam(new SeasonTeam() { Parent = new Team() { Name = "Team " + i, Id = i }, Id = i * 100, Name = "Team " + i }); } season.AddDivision(league); Assert.StrictEqual(0, season.Teams.Count); season.AddDivision(conference); Assert.StrictEqual(10, season.Teams.Count); }
public void ShouldAddDivisionToSeasonOnlyTopLevelDivision() { var season = new Season() { Number = 1, Year = 1, Name = "First Season" }; var league = new SeasonDivision("League", season, DivisionLevel.League, null, null, null); for (int i = 0; i < 10; i++) { league.AddTeam(new SeasonTeam() { Parent = new Team() { Name = "Team " + i, Id = i }, Id = i * 100, Name = "Team " + i }); } season.AddDivision(league); Assert.StrictEqual(10, season.Teams.Count); season.Teams.ToList().ForEach(team => { Assert.NotNull(team.Competition); }); Assert.NotNull(league.Season); }
public async Task <Guid> Handle(CreateSeasonCommand request, CancellationToken cancellationToken) { var season = new Season(request.StartDate); foreach (var division in request.Divisions) { season.AddDivision( division.Name, division.Hierarchy, division.NumberOfDegraded ?? 0, division.NumberOfPromoted ?? 0); } await this.repository.Save(season); return(season.Id.Value); }
public override void Given() { viewModel = new CreateDivisionViewModel(); viewModel.Name = "MyDivision"; viewModel.StartingDate = DateTime.Parse("11/30/2010").ToShortDateString(); viewModel.SeasonId = 1; var season = new Season("temp", GameType.EightBall); var division = new Division(viewModel.Name, DateTime.Now, season); season.SetIdTo(viewModel.SeasonId); season.AddDivision(division); repository.Setup(r => r.Get<Season>(season.Id)).Returns(season); var divisions = new List<Division> { division }; repository.Setup(r => r.All<Division>()).Returns(divisions.AsQueryable()); }