Exemplo n.º 1
0
        public void RollTest()
        {
            List <int> rollResults = new List <int>();
            IRollable  d           = DiceFactory.CreateD10();

            for (int i = 0; i < 100000000; i++)
            {
                rollResults.Add(d.Roll());
            }
            Assert.AreEqual(rollResults.Count, 100000000, "Count is " + rollResults.Count.ToString());
        }
Exemplo n.º 2
0
        public void TestAllD10Values()
        {
            // create D10
            var d = DiceFactory.CreateD10();

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

            notFound.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

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