public void ShouldGetTeamsWithChildrenAndDoesNotHaveTeams() { var division = new SeasonDivision() { Name = "Parent Div" }; var child1 = new SeasonDivision() { Name = "Child 1" }; var child2 = new SeasonDivision() { Name = "Child 2" }; child1.AddTeam(new SeasonTeam() { Name = "Team 1" }); child1.AddTeam(new SeasonTeam() { Name = "Team 2" }); child1.AddTeam(new SeasonTeam() { Name = "Team 3" }); child1.AddTeam(new SeasonTeam() { Name = "Team 4" }); child1.AddTeam(new SeasonTeam() { Name = "Team 5" }); child2.AddTeam(new SeasonTeam() { Name = "Team 6" }); child2.AddTeam(new SeasonTeam() { Name = "Team 7" }); child2.AddTeam(new SeasonTeam() { Name = "Team 8" }); child1.AddChildDivision(child2); division.AddChildDivision(child1); Assert.StrictEqual(8, division.Teams.Count); Assert.StrictEqual(8, child1.Teams.Count); Assert.StrictEqual(3, child2.Teams.Count); }
public SeasonDivision CreateAndAddDivision(Season season, SeasonDivision parent, IList <SeasonDivision> masterList, SeasonDivisionRule rule) { var newDiv = new SeasonDivision(rule.Name, season, rule.Level, parent); rule.Children.ToList().ForEach(cdr => { newDiv.AddChildDivision(CreateAndAddDivision(season, newDiv, masterList, cdr)); }); masterList.Add(newDiv); return(newDiv); }