Beispiel #1
0
            public void Should_Generate_Configured_RepeatCount()
            {
                var count    = _faker.Random.Int(3, 5);
                var expected = Enumerable.Range(0, count).Select(i => _value).ToList();

                _config.RepeatCount = context => count;

                AutoGenerateContextExtensions.GenerateMany(_context, null, _items, false, 1, () => _value);

                _items.Should().BeEquivalentTo(expected);
            }
Beispiel #2
0
            public void Should_Short_Circuit_If_Unique_Attempts_Overflow()
            {
                var attempts = 0;

                AutoGenerateContextExtensions.GenerateMany(_context, 2, _items, true, 1, () =>
                {
                    attempts++;
                    return(_value);
                });

                attempts.Should().Be(AutoConfig.GenerateAttemptsThreshold);

                _items.Should().BeEquivalentTo(new[] { _value });
            }
Beispiel #3
0
            public void Should_Not_Generate_Duplicates_If_Unique()
            {
                var first  = _value;
                var second = _faker.Random.Int();

                AutoGenerateContextExtensions.GenerateMany(_context, 2, _items, true, 1, () =>
                {
                    var item = _value;
                    _value   = second;

                    return(item);
                });

                _items.Should().BeEquivalentTo(new[] { first, second });
            }
Beispiel #4
0
            public void Should_Generate_Duplicates_If_Not_Unique()
            {
                AutoGenerateContextExtensions.GenerateMany(_context, 2, _items, false, 1, () => _value);

                _items.Should().BeEquivalentTo(new[] { _value, _value });
            }