public void CreateRandomValueTest()
 {
     RandomValue target = new RandomValue(); // TODO: 初始化為適當值
     List<int> temp = new List<int>();
     for(int i =0 ;i<10000;i++)
     {
         temp.Add(target.CreateRandomValue(0, 100));
     }
     for(int i=0; i<100;i++)
         Assert.AreEqual(true, temp.Contains(i));
 }
Example #2
0
        virtual public void CreateNewQuestion()  //產生填充題
        {
            int          testLibraryIndex;       //題庫索引位置
            const string FIVE_BLANK   = "     "; //五個空格
            bool         continueFlag = true;

            do  //取得新的題庫索引位置(尚未考過的)
            {
                testLibraryIndex = _randomValue.CreateRandomValue(0, _questionLibrary.NumberOfVocabulary);
                if (!_isTestedIndex.Contains(testLibraryIndex))
                {
                    _isTestedIndex.Add(testLibraryIndex);
                    continueFlag = false;
                }
            } while (continueFlag);
            _testedVocabulary = _questionLibrary.GetWord(testLibraryIndex);                     //根據所以取得單字
            int tipIndex = _randomValue.CreateRandomValue(1, _testedVocabulary.English.Length); //提示索引位置

            _questionStatement = _testedVocabulary.Chinese + FIVE_BLANK;                        //將題目字串先加入中文
            AddEnglishTipToQuetionStatement(tipIndex);
        }