コード例 #1
0
        public void Test__SystemRng__NextMinMaxValue02__ExpectException()
        {
            const int minValue = 2;
            const int maxValue = 1;

            IPsuedoRandomNumberGenerator generator = Factory.SystemRngPump.NewInstance();

            Assert.Throws <ArgumentOutOfRangeException>(() => generator.Next(minValue, maxValue));
        }
コード例 #2
0
        public void Test__SystemRng__NextMaxValue04__ExpectLessThan()
        {
            const int maxValue = int.MaxValue;

            IPsuedoRandomNumberGenerator generator = Factory.SystemRngPump.NewInstance();
            var actual = generator.Next(maxValue);

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual < maxValue);
        }
コード例 #3
0
        public void Test__SystemRng__NextMaxValue__ExpectAreEqual()
        {
            const int maxValue = 0;

            IPsuedoRandomNumberGenerator generator = Factory.SystemRngPump.NewInstance();
            var actual = generator.Next(maxValue);

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual, maxValue);
        }
コード例 #4
0
        public void Test__SystemRng__NextMinMaxValue05__ExpectRange()
        {
            const int minValue = -1;
            const int maxValue = 1;

            IPsuedoRandomNumberGenerator generator = Factory.SystemRngPump.NewInstance();
            var actual = generator.Next(minValue, maxValue);

            Assert.IsNotNull(actual);
            Assert.IsTrue(actual < maxValue);
            Assert.IsTrue(actual >= minValue);
        }
コード例 #5
0
        public void Test__SystemRng__Next__ExpectSomeIntegerValues()
        {
            const int numGenerations = 1000000; // test one meellion iterations

            IPsuedoRandomNumberGenerator generator = Factory.SystemRngPump.NewInstance();

            for (var i = 0; i < numGenerations; i++)
            {
                var actual = generator.Next();

                Assert.IsNotNull(actual);
                Assert.IsTrue(actual >= 0);
                Assert.IsTrue(actual < int.MaxValue);
            }
        }
コード例 #6
0
        public void Test__SystemRng__NextMaxValue01__ExpectException()
        {
            IPsuedoRandomNumberGenerator generator = Factory.SystemRngPump.NewInstance();

            Assert.Throws <ArgumentOutOfRangeException>(() => generator.Next(-1));
        }