コード例 #1
0
ファイル: MatchTest.cs プロジェクト: oskar/dlcup
        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
ファイル: GameTest.cs プロジェクト: oskar/dlcup
 private void WinningTeamTestHelper(int? homeScore, int? guestScore, PlayingTeam expectedWinningTeam)
 {
     var g = new Game() { HomeScore = homeScore, GuestScore = guestScore };
     Assert.AreEqual(expectedWinningTeam, g.WinningTeam);
 }