ModelBuilder.UnitTests.AgeValueGeneratorTests.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 AgeValueGenerator();

            var value = target.Generate(type, "Age", null);

            if (type.IsNullable()
                &&
                value == null)
            {
                // We can't run the assertions because null is a valid outcome
                return;
            }

            var evaluateType = type;

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

            value.Should().BeOfType(evaluateType);

            var convertedValue = Convert.ToDouble(value);

            convertedValue.Should().BeLessOrEqualTo(target.MaxAge);
            convertedValue.Should().BeGreaterOrEqualTo(1);
        }