Пример #1
0
 public void GenerateInt_DoesNotThrow()
 {
     using (var rngesus = new RNGesus())
     {
         Assert.DoesNotThrow(() => rngesus.GenerateInt());
     }
 }
Пример #2
0
 public void GenerateInt_Minimum_Maximum_DoesNotThrow(uint minimum, uint maximum)
 {
     using (var rngesus = new RNGesus())
     {
         Assert.DoesNotThrow(() => rngesus.GenerateInt(minimum, maximum));
     }
 }
Пример #3
0
 public void GenerateInt_Minimum_Maximum_Throws_AEx(int minimum, int maximum)
 {
     using (var rngesus = new RNGesus())
     {
         Assert.Throws <ArgumentException>(() => rngesus.GenerateInt(minimum, maximum));
     }
 }
Пример #4
0
        public void SharedBufferTest()
        {
            const int iterations     = 999;
            var       integerResults = new int[iterations];
            var       longResults    = new long[iterations];
            var       boolResults    = new bool[iterations];
            var       floatResults   = new float[iterations];
            var       doubleResults  = new double[iterations];
            var       byteResults    = new byte[iterations][];
            var       stringResults  = new string[iterations];

            using (var rngesus = new RNGesus())
            {
                for (var i = 0; i < iterations; i++)
                {
                    integerResults[i] = rngesus.GenerateInt();
                }

                for (var i = 0; i < iterations; i++)
                {
                    longResults[i] = rngesus.GenerateLong();
                }

                for (var i = 0; i < iterations; i++)
                {
                    boolResults[i] = rngesus.GenerateBool();
                }

                for (var i = 0; i < iterations; i++)
                {
                    floatResults[i] = rngesus.GenerateFloat();
                }

                for (var i = 0; i < iterations; i++)
                {
                    doubleResults[i] = rngesus.GenerateDouble();
                }

                for (var i = 0; i < iterations; i++)
                {
                    byteResults[i] = rngesus.GenerateByteArray(99);
                }

                for (var i = 0; i < iterations; i++)
                {
                    stringResults[i] = rngesus.GenerateString(99);
                }
            }

            Assert.That(integerResults.Length == iterations);
            Assert.That(longResults.Length == iterations);
            Assert.That(boolResults.Length == iterations);
            Assert.That(floatResults.Length == iterations);
            Assert.That(doubleResults.Length == iterations);
            Assert.That(byteResults.Length == iterations);
            Assert.That(stringResults.Length == iterations);
        }
Пример #5
0
        public void GenerateInt_MinimumAndMaximum_ReturnsInRange()
        {
            using (var rngesus = new RNGesus())
            {
                var result = rngesus.GenerateInt(999, 999999);

                Assert.That(() => result >= 999);
                Assert.That(() => result <= 999999);
            }
        }
Пример #6
0
        public void LockTest()
        {
            var result = "";

            using (var rngesus = new RNGesus(9999))
            {
                result = rngesus.GenerateString(rngesus.GenerateInt(999, 9999));
            }

            Assert.That(result.Length >= 999);
            Assert.That(result.Length <= 9999);
        }
Пример #7
0
        public void GenerateInt_MinimumAndMaximum_ReturnsNoDuplicates()
        {
            var results = new int[9];

            for (var i = 0; i < results.Length; i++)
            {
                using (var rngesus = new RNGesus())
                {
                    results[i] = rngesus.GenerateInt(999, 999999);
                }
            }

            Assert.That(results.Distinct().Count() == results.Count());
        }