private void Validate <T>(OptionSettingItem optionSettingItem, T value, bool isValid) { ValidationFailedException exception = null; try { optionSettingItem.SetValueOverride(value); } catch (ValidationFailedException e) { exception = e; } if (isValid) { exception.ShouldBeNull(); } else { exception.ShouldNotBeNull(); } }
public void ValidInputDoesNotThrowException() { var validValue = 8; var optionSettingItem = new OptionSettingItem("id", "name", "description") { Validators = new() { new OptionSettingItemValidatorConfig { ValidatorType = OptionSettingItemValidatorList.Range, Configuration = new RangeValidator { Min = 7, Max = 10 } }, new OptionSettingItemValidatorConfig { ValidatorType = OptionSettingItemValidatorList.Required } } }; ValidationFailedException exception = null; // ACT try { optionSettingItem.SetValueOverride(validValue); } catch (ValidationFailedException e) { exception = e; } exception.ShouldBeNull(); }