Exemplo n.º 1
0
        public void CanCreateMatchSetResult()
        {
            var season = new Season()
            {
                Name = seasonName, Id = 310
            };
            var week = new MatchSet()
            {
                Date = matchSetDate
            };
            var matchSet = season.AddWeek(week);

            var golfer1 = new Golfer()
            {
                Id             = 1,
                LeagueHandicap = 10
            };

            var golfer2 = new Golfer
            {
                Id             = 2,
                LeagueHandicap = 7
            };

            var match = matchSet.AddResult(golfer1, 3, 3.5m, true, golfer2, 2, 7.5m, false);

            Assert.Equal(1, matchSet.Matches.Count);
            Assert.Equal(11, matchSet.Matches.First().Players.Sum(p => p.Points));
        }
        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);
        }
Exemplo n.º 3
0
        public void CanCeateSetOfMatches()
        {
            var season = new Season()
            {
                Name = seasonName, Id = 103
            };
            var week     = new MatchSet(matchSetDate);
            var matchSet = season.AddWeek(week);

            Assert.Equal(103, matchSet.SeasonId);
            Assert.Equal(matchSetDate, matchSet.Date);
        }
Exemplo n.º 4
0
        public void MatchPointsAlwaysTotalEleven(decimal scoreA, decimal scoreB)
        {
            var season = new Season()
            {
                Name = seasonName
            };
            var matchSet = new MatchSet(matchSetDate);

            season.AddWeek(matchSet);

            var golfer1 = new Golfer {
                Id = 1, LeagueHandicap = 10
            };
            var golfer2 = new Golfer {
                Id = 2, LeagueHandicap = 7
            };


            var match = matchSet.AddResult(golfer1, 3, scoreA, true, golfer2, 2, scoreB, false);

            Assert.Equal(11, match.Players.Sum(p => p.Points));
        }