Пример #1
0
 public Player(string firstName, string lastName, Country country)
 {
     if (country == null) throw new ArgumentNullException("country");
     this.firstName = firstName;
     this.lastName = lastName;
     this.country = country;
 }
Пример #2
0
        // factory method example. this one could have been normal constructor
        public static Match Create(DateTime date, Country team1Country, Country team2Country)
        {
            if (team1Country == null) throw new ArgumentNullException("team1Country");
            if (team2Country == null) throw new ArgumentNullException("team2Country");
            if (team1Country.Equals(team2Country)) throw new ArgumentException("Teams must not be the same country!");

            var match = new Match { date = date };
            match.teams.Add(new Team(match, team1Country));
            match.teams.Add(new Team(match, team2Country));
            return match;
        }
Пример #3
0
        public Country SetUpCountry(string countryName)
        {
            using (var uow = unitOfWorkFactory.BeginUnitOfWork())
            {
                var country = uow.Query<Country>().SingleOrDefault(x => x.Name == countryName);
                if (country != null)
                    return country;

                country = new Country(countryName);

                uow.Add(country);

                uow.Complete();

                return country;
            }
        }
Пример #4
0
        public int SetUpMatch(Country country1, Country country2)
        {
            PopulateCountryPlayerPool(country1.Name);
            PopulateCountryPlayerPool(country2.Name);

            using (var uow = unitOfWorkFactory.BeginUnitOfWork())
            {
                var match = Match.Create(DateTime.Today, country1, country2);

                PickTeam(match.Team1, uow);
                PickTeam(match.Team2, uow);

                uow.Add(match);

                uow.Complete();

                return match.Id;
            }
        }
Пример #5
0
 internal Team(Match match, Country country)
 {
     this.match = match;
     this.country = country;
 }
Пример #6
0
 internal Team(Match match, Country country)
 {
     Match = match;
     Country = country;
 }
Пример #7
0
 public virtual void ChangeCountry(Country country)
 {
     if (country == null) throw new ArgumentNullException("country");
     this.country = country;
 }