public void LongValueGenerator_should_generate_value_from_normalize(long min, long max, int step, bool logbase, long expect) { var option = new LongValueGenerator.Option() { Min = min, Max = max, Name = "long", Steps = step, LogBase = logbase, }; var generator = new LongValueGenerator(option); generator.CreateFromNormalized(1.0).RawValue.Should().Be(max); generator.CreateFromNormalized(0).RawValue.Should().Be(min); generator.CreateFromNormalized(0.5).RawValue.Should().Be(expect); }
public void TestLongValueGeneratorRoundTrip() { var paramSweep = new LongValueGenerator(new LongParamArguments() { Name = "bla", Min = 0, Max = 17 }); var value = new LongParameterValue("bla", 5); float normalizedValue = paramSweep.NormalizeValue(value); IParameterValue unNormalizedValue = paramSweep.CreateFromNormalized(normalizedValue); Assert.Equal("5", unNormalizedValue.ValueText); IParameterValue param = paramSweep.CreateFromNormalized(0.345); float unNormalizedParam = paramSweep.NormalizeValue(param); Assert.Equal("5", param.ValueText); Assert.Equal((float)5 / 17, unNormalizedParam); }
public void TestLongValueSweep(string name, int min, int max, bool logBase, int stepSize, int numSteps, string valueText) { var paramSweep = new LongValueGenerator(new LongParamArguments() { Name = name, Min = min, Max = max, LogBase = logBase, StepSize = stepSize, NumSteps = numSteps }); IParameterValue value = paramSweep.CreateFromNormalized(0.5); Assert.Equal(name, value.Name); Assert.Equal(valueText, value.ValueText); }