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

GenerateReturnsNewValueTest() private method

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

            var target = new CountValueGenerator();

            var value = target.Generate(type, "Count", 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.MaxCount);
            convertedValue.Should().BeGreaterOrEqualTo(1);
        }