Esempio n. 1
0
        public void NextInt64Test()
        {
            using var rng = new RandomNonceGenerator();
            long actual1 = rng.NextInt64();
            long actual2 = rng.NextInt64();

            Assert.NotEqual(actual1, actual2);
        }
Esempio n. 2
0
        public void GetDistinct_ExceptionTest(int min, int max, int count, string err)
        {
            using var rng = new RandomNonceGenerator();

            Exception ex = Assert.Throws <ArgumentOutOfRangeException>(() => rng.GetDistinct(min, max, count));

            Assert.Contains(err, ex.Message);
        }
Esempio n. 3
0
        public void DisposedExceptionTest()
        {
            var rng = new RandomNonceGenerator();

            rng.Dispose();

            Assert.Throws <ObjectDisposedException>(() => rng.NextInt32());
            Assert.Throws <ObjectDisposedException>(() => rng.NextInt64());
        }
Esempio n. 4
0
        public void NextInt32_MinMaxTest()
        {
            using var rng = new RandomNonceGenerator();
            int min    = 1;
            int max    = 5;
            int actual = rng.NextInt32(min, max);

            Assert.True(actual >= min);
            Assert.True(actual < max);
        }
Esempio n. 5
0
        public void GetDistinctTest()
        {
            using var rng = new RandomNonceGenerator();
            for (int count = 0; count < 10; count++)
            {
                int[] actual   = rng.GetDistinct(0, 10, count);
                int[] expected = actual.Distinct().ToArray();

                Assert.Equal(expected, actual);
            }
        }