Ejemplo n.º 1
0
        public void MastersHandicap_WithCrewNotInMastersCompetition_ShouldThrowInvalidOperationException()
        {
            Crew crew = new Crew();

            crew.Athletes.Add(new CrewAthlete {
                Athlete = new Athlete(), Age = 27
            });

            Assert.ThrowsException <InvalidOperationException>(() => crew.CalculateMastersHandicap(new Dictionary <MastersCategory, int>(), new Dictionary <MastersCategory, int>()));
        }
Ejemplo n.º 2
0
        public void MastersHandicap_WithMastersACrew_ShouldReturnZero()
        {
            Crew crew = new Crew();

            crew.Athletes.Add(new CrewAthlete {
                Athlete = new Athlete(), Age = 27
            });
            Award award = new Award {
                IsMasters = true, AwardId = 1
            };

            crew.Awards.Add(new CrewAward()
            {
                Award = award
            });

            Assert.AreEqual(0, crew.CalculateMastersHandicap(new Dictionary <MastersCategory, int>(), new Dictionary <MastersCategory, int>()));
        }
Ejemplo n.º 3
0
        public void MastersHandicap_WithNonMastersCrew_ShouldThrowInvalidOperationException()
        {
            Crew crew = new Crew();

            crew.Athletes.Add(new CrewAthlete {
                Athlete = new Athlete(), Age = 26
            });
            Award award = new Award {
                IsMasters = true, AwardId = 1
            };

            crew.Awards.Add(new CrewAward()
            {
                Award = award
            });

            Assert.ThrowsException <InvalidOperationException>(() => crew.CalculateMastersHandicap(new Dictionary <MastersCategory, int>(), new Dictionary <MastersCategory, int>()));
        }
Ejemplo n.º 4
0
        public void MastersHandicap_WithMastersCrew_ShouldReturnCorrectHandicap(int age, int minutes, int seconds, int handicap)
        {
            Competition competition = new Competition();

            competition.TimingPoints.Add(new TimingPoint {
                TimingPointId = 1
            });
            competition.TimingPoints.Add(new TimingPoint {
                TimingPointId = 2
            });
            Award award = new Award {
                IsMasters = true, AwardId = 1
            };

            competition.Awards.Add(award);
            Crew crewOne = new Crew();

            crewOne.Results.Add(new Result {
                TimingPointId = 1, TimeOfDay = new TimeSpan(10, 0, 0)
            });
            crewOne.Results.Add(new Result {
                TimingPointId = 2, TimeOfDay = new TimeSpan(10, minutes, seconds)
            });
            crewOne.Awards.Add(new CrewAward {
                Award = award
            });
            crewOne.Athletes.Add(new CrewAthlete {
                Athlete = new Athlete(), Age = 27
            });
            award.Crews.Add(new CrewAward {
                Crew = crewOne
            });
            crewOne.Competition = competition;
            competition.Crews.Add(crewOne);
            Crew crewTwo = new Crew();

            crewTwo.Results.Add(new Result {
                TimingPointId = 1, TimeOfDay = new TimeSpan(10, 0, 0)
            });
            crewTwo.Results.Add(new Result {
                TimingPointId = 2, TimeOfDay = new TimeSpan(10, minutes, seconds + 20)
            });
            crewTwo.Awards.Add(new CrewAward {
                Award = award
            });
            crewTwo.Athletes.Add(new CrewAthlete {
                Athlete = new Athlete(), Age = age
            });
            crewTwo.Competition = competition;
            award.Crews.Add(new CrewAward {
                Crew = crewTwo
            });
            competition.Crews.Add(crewTwo);

            Dictionary <MastersCategory, int> lowerBounds = new Dictionary <MastersCategory, int>();

            lowerBounds.Add(MastersCategory.B, handicap);
            Dictionary <MastersCategory, int> upperBounds = new Dictionary <MastersCategory, int>();

            upperBounds.Add(MastersCategory.B, handicap);

            Assert.AreEqual(handicap, crewTwo.CalculateMastersHandicap(lowerBounds, upperBounds));
        }