Example #1
0
        public void Int32GeneratorTest()
        {
            var g = new SequentialInt32Generator();

            g.Next().Should().Be(1);
            g.Next().Should().Be(2);
            g.Next().Should().Be(3);
        }
        public void Generate_start_stop_step_sequence_ok(int start, int stop, int step, int[] expectedOutput)
        {
            var generator = new SequentialInt32Generator
            {
                Start = start,
                End = stop,
                Step = step
            };

            var actualOutput = generator.Run().Cast<int>();
            Assert.AreElementsEqual(expectedOutput, actualOutput);
        }
        public void Generate_sequence_with_invalid_property_settings_should_throw_exception(int?start, int?stop, int?step, int?count)
        {
            var generator = new SequentialInt32Generator
            {
                Start = start,
                End   = stop,
                Step  = step,
                Count = count
            };

            Assert.Throws <GenerationException>(() => generator.Run().Cast <int>().ToArray());
        }
        public void Generate_start_stop_step_sequence_ok(int start, int stop, int step, int[] expectedOutput)
        {
            var generator = new SequentialInt32Generator
            {
                Start = start,
                End   = stop,
                Step  = step
            };

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

            Assert.AreElementsEqual(expectedOutput, actualOutput);
        }
        public void Generate_filtered_sequence()
        {
            var generator = new SequentialInt32Generator
            {
                Start  = 0,
                End    = 100,
                Step   = 1,
                Filter = IsPrime
            };

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

            Assert.AreElementsEqual(new[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 }, actualOutput);
        }
            private static IEnumerable <int> NumbersImpl(int?start, int?end, int?step, int?count)
            {
                var generator = new SequentialInt32Generator
                {
                    Start = start,
                    End   = end,
                    Step  = step,
                    Count = count,
                };

                foreach (int value in generator.Run())
                {
                    yield return(value);
                }
            }
        public void Generate_filtered_sequence()
        {
            var generator = new SequentialInt32Generator
            {
                Start = 0,
                End = 100,
                Step = 1,
                Filter = IsPrime
            };

            var actualOutput = generator.Run().Cast<int>();
            Assert.AreElementsEqual(new[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 }, actualOutput);
        }
        public void Generate_sequence_with_invalid_property_settings_should_throw_exception(int? start, int? stop, int? step, int? count)
        {
            var generator = new SequentialInt32Generator
            {
                Start = start,
                End = stop,
                Step = step,
                Count = count
            };

            Assert.Throws<GenerationException>(() => generator.Run().Cast<int>().ToArray());
        }
            private static IEnumerable<int> NumbersImpl(int? start, int? end, int? step, int? count)
            {
                var generator = new SequentialInt32Generator
                {
                    Start = start,
                    End = end,
                    Step = step,
                    Count = count,
                };

                foreach (int value in generator.Run())
                    yield return value;
            }