ModelBuilder.UnitTests.NumericValueGeneratorTests.GenerateReturnsNewValueTest C# (CSharp) Method

GenerateReturnsNewValueTest() private method

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

            var target = new NumericValueGenerator();

            var value = target.Generate(type, null, 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);
        }