Example #1
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);
        }
Example #2
0
        public void DisposedExceptionTest()
        {
            var rng = new RandomNonceGenerator();

            rng.Dispose();

            Assert.Throws <ObjectDisposedException>(() => rng.NextInt32());
            Assert.Throws <ObjectDisposedException>(() => rng.NextInt32(1, 2));
            Assert.Throws <ObjectDisposedException>(() => rng.NextInt64());
            Assert.Throws <ObjectDisposedException>(() => rng.GetDistinct(0, 10, 2));
        }
Example #3
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);
            }
        }