public void Constructs_with_invalid_property_should_throw_exception(int minimum, int maximum, int count)
        {
            var generator = new RandomInt32Generator
            {
                Minimum = minimum,
                Maximum = maximum,
                Count = count
            };

            Assert.Throws<GenerationException>(() => generator.Run().Cast<int>().ToArray());
        }
예제 #2
0
        public void Constructs_with_invalid_property_should_throw_exception(int minimum, int maximum, int count)
        {
            var generator = new RandomInt32Generator
            {
                Minimum = minimum,
                Maximum = maximum,
                Count   = count
            };

            Assert.Throws <GenerationException>(() => generator.Run().Cast <int>().ToArray());
        }
        public void WriteBigEndianInt32Array()
        {
            var integers = new RandomInt32Generator(1).Structs;

            using (var extendedStream = new BigEndianMemoryStream(new Reloaded.Memory.Streams.ExtendedMemoryStream()))
            {
                extendedStream.Write(integers);
                Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive <Int32>(extendedStream.ToArray(), out var newStructs);

                Assert.Equal(integers, newStructs);
            };
        }
예제 #4
0
            /// <summary>
            /// Returns the an enumeration of random numbers.
            /// </summary>
            /// <param name="count">The number of strings to generate.</param>
            /// <param name="minimum">The lower bound of the range.</param>
            /// <param name="maximum">The upper bound of the range.</param>
            /// <returns>An enumeration of random number values.</returns>
            /// <exception cref="GenerationException">Thrown if the specified parameters are inconsistent or invalid.</exception>
            public static IEnumerable <int> Numbers(int count, int minimum, int maximum)
            {
                var generator = new RandomInt32Generator
                {
                    Count   = count,
                    Minimum = minimum,
                    Maximum = maximum,
                };

                foreach (int value in generator.Run())
                {
                    yield return(value);
                }
            }
        public void Generate_sequence_ok(int minimum, int maximum, int count)
        {
            var generator = new RandomInt32Generator
            {
                Minimum = minimum,
                Maximum = maximum,
                Count = count
            };

            var values = generator.Run().Cast<int>().ToArray();
            Assert.Count(count, values);
            Assert.Multiple(() =>
            {
                foreach (int value in values)
                {
                    Assert.Between(value, minimum, maximum);
                }
            });
        }
예제 #6
0
        public void Generate_sequence_ok(int minimum, int maximum, int count)
        {
            var generator = new RandomInt32Generator
            {
                Minimum = minimum,
                Maximum = maximum,
                Count   = count
            };

            var values = generator.Run().Cast <int>().ToArray();

            Assert.Count(count, values);
            Assert.Multiple(() =>
            {
                foreach (int value in values)
                {
                    Assert.Between(value, minimum, maximum);
                }
            });
        }
예제 #7
0
        public void Generate_filtered_sequence()
        {
            var generator = new RandomInt32Generator
            {
                Minimum = 0,
                Maximum = 100,
                Count   = 50,
                Filter  = d => (d % 2) == 0
            };

            var values = generator.Run().Cast <int>().ToArray();

            Assert.Count(50, values);
            Assert.Multiple(() =>
            {
                foreach (int value in values)
                {
                    Assert.AreEqual(0, value % 2);
                }
            });
        }
            /// <summary>
            /// Returns the an enumeration of random numbers.
            /// </summary>
            /// <param name="count">The number of strings to generate.</param>
            /// <param name="minimum">The lower bound of the range.</param>
            /// <param name="maximum">The upper bound of the range.</param>
            /// <returns>An enumeration of random number values.</returns>
            /// <exception cref="GenerationException">Thrown if the specified parameters are inconsistent or invalid.</exception>
            public static IEnumerable<int> Numbers(int count, int minimum, int maximum)
            {
                var generator = new RandomInt32Generator
                {
                    Count = count,
                    Minimum = minimum,
                    Maximum = maximum,
                };

                foreach (int value in generator.Run())
                    yield return value;
            }
예제 #9
0
 public void Setup()
 {
     _generator = new RandomInt32Generator(TotalDataMB);
 }
 /* Construction/Destruction */
 public BufferedStreamReader()
 {
     _randomIntStructGenerator = new RandomIntStructGenerator(StructBytesMB);
     _randomIntegerGenerator   = new RandomInt32Generator(StructBytesMB);
 }
        public void Generate_filtered_sequence()
        {
            var generator = new RandomInt32Generator
            {
                Minimum = 0,
                Maximum = 100,
                Count = 50,
                Filter = d => (d % 2) == 0
            };

            var values = generator.Run().Cast<int>().ToArray();
            Assert.Count(50, values);
            Assert.Multiple(() =>
            {
                foreach (int value in values)
                {
                    Assert.AreEqual(0, value % 2);
                }
            });
        }