ModelBuilder.UnitTests.CountValueGeneratorTests.GenerateCanEvalutateManyTimesTest C# (CSharp) Method

GenerateCanEvalutateManyTimesTest() private method

private GenerateCanEvalutateManyTimesTest ( Type type, bool isSupported, double min, double max ) : void
type System.Type
isSupported bool
min double
max double
return void
        public void GenerateCanEvalutateManyTimesTest(Type type, bool isSupported, double min, double max)
        {
            if (isSupported == false)
            {
                // Ignore this test
                return;
            }

            var target = new CountValueGenerator();

            for (var index = 0; index < 10000; index++)
            {
                var value = target.Generate(type, "Count", null);

                if (type.IsNullable() &&
                    value == null)
                {
                    // Nullable values could be returned so nothing more to assert
                    return;
                }

                var evaluateType = type;

                if (type.IsNullable())
                {
                    evaluateType = type.GenericTypeArguments[0];
                }

                value.Should().BeOfType(evaluateType);

                var convertedValue = Convert.ToDouble(value);

                convertedValue.Should().BeGreaterOrEqualTo(min);
                convertedValue.Should().BeLessOrEqualTo(max);
            }
        }