예제 #1
0
 public void TestRoundGeneration()
 {
     CBase.Game = new CBGame();
     CLog.Init();
     CBase.Log = new CBlog();
     for (int i = 0; i < 10; i++)
     {
         for (int numPlayer = 1; numPlayer <= 20; numPlayer++)
         {
             for (int numMic = 1; numMic <= 6; numMic++)
             {
                 int roundFactor = (numPlayer % numMic == 0) ? numPlayer / numMic : numPlayer;
                 for (int numRounds = roundFactor; numRounds <= 100 && numRounds <= roundFactor * 5; numRounds += roundFactor)
                 {
                     CChallengeRounds rounds = new CChallengeRounds(numRounds, numPlayer, numMic);
                     Assert.IsTrue(rounds.Count >= numRounds);
                     _CheckRounds(rounds, numPlayer);
                     if (rounds.Count != numRounds)
                     {
                         CBase.Log.LogDebug("Number of rounds does not match. Expected: " + numRounds + ", Is: " + rounds.Count + " for " + numPlayer + "/" +
                                            ((numPlayer < numMic) ? numPlayer : numMic));
                     }
                 }
             }
         }
     }
 }
예제 #2
0
        public void TestRoundGeneration([Range(1, 20)] int numPlayer, [Range(1, 6)] int numMic)
        {
            CBase.Game = new CBGame();

            int roundFactor = (numPlayer % numMic == 0) ? numPlayer / numMic : numPlayer;

            for (int numRounds = roundFactor; numRounds <= 100 && numRounds <= roundFactor * 5; numRounds += roundFactor)
            {
                CChallengeRounds rounds = new CChallengeRounds(numRounds, numPlayer, numMic);
                Assert.IsTrue(rounds.Count >= numRounds);
                _CheckRounds(rounds, numPlayer);
                Warn.If(rounds.Count != numRounds,
                        $"Number of rounds does not match. Expected: {numRounds}, Is: {rounds.Count} for {numPlayer}/{((numPlayer < numMic) ? numPlayer : numMic)}");
            }
        }
예제 #3
0
        private static void _CheckRounds(CChallengeRounds rounds, int numPlayer)
        {
            List <int> numSongs = new List <int>(numPlayer);

            for (int i = 0; i < numPlayer; i++)
            {
                numSongs.Add(0);
            }
            for (int i = 0; i < rounds.Count; i++)
            {
                foreach (int player in rounds[i].Players)
                {
                    Assert.IsTrue(player >= 0 && player < numPlayer);
                    numSongs[player]++;
                }
            }
            Assert.IsTrue(numSongs.Min() == numSongs.Max(), "Some players have more songs than others");
        }