예제 #1
0
        public void TestAllCoinValues()
        {
            // create Coin
            var d = DiceFactory.CreateCoin();

            // populate "not yet found" list
            List <int> notFound = new List <int>();

            notFound.AddRange(new int[] { 1, 2 });

            // attempt to find each value
            for (int i = 1; i < 10; i++)               // arbitrary limit of 10 maximum tries
            {
                int result = d.Roll();                 // 1 To 2
                notFound.Remove(result);
                if (notFound.Count <= 0)
                {
                    break;                     // all found
                }
            }
            // test
            Assert.AreEqual <int>(0, notFound.Count, "Some values were not rolled on a coin.");
        }