Пример #1
0
        private void WinningTeamTestHelper(int homeGames, int guestGames, int totalGames, PlayingTeam expectedWinningTeam)
        {
            var noneGames = totalGames - homeGames - guestGames;
            if (noneGames < 0)
                throw new ArgumentException("Totalt antal set är mindre än hemmaset + bortaset");

            var m = new Match();

            for (int i = 0; i < homeGames; i++)
            {
                var homeGame = new Game() { HomeScore = 11, GuestScore = 0 };
                Assert.AreEqual(PlayingTeam.HomeTeam, homeGame.WinningTeam);

                m.Games.Add(homeGame);
            }

            for (int i = 0; i < guestGames; i++)
            {
                var guestGame = new Game() { HomeScore = 0, GuestScore = 11 };
                Assert.AreEqual(PlayingTeam.GuestTeam, guestGame.WinningTeam);

                m.Games.Add(guestGame);
            }

            for (int i = 0; i < noneGames; i++)
            {
                var noneGame = new Game();
                Assert.AreEqual(PlayingTeam.None, noneGame.WinningTeam);

                m.Games.Add(noneGame);
            }

            Assert.AreEqual(expectedWinningTeam, m.WinningTeam);
        }
Пример #2
0
        private void FixupMatch(Match previousValue)
        {
            if (previousValue != null && previousValue.Games.Contains(this))
            {
                previousValue.Games.Remove(this);
            }

            if (Match != null)
            {
                if (!Match.Games.Contains(this))
                {
                    Match.Games.Add(this);
                }
            }
        }