/// <summary> /// Validates that the usage of the settings will result in a ValidationException thrown /// with the expected error message and member names. /// </summary> private void ValidateFieldValidation(EventCounterTriggerSettings settings, string expectedMessage, string[] expectedMemberNames) { var exception = Assert.Throws <ValidationException>(() => new EventCounterTrigger(settings)); Assert.NotNull(exception.ValidationResult); Assert.Equal(expectedMessage, exception.ValidationResult.ErrorMessage); Assert.Equal(expectedMemberNames, exception.ValidationResult.MemberNames); }
/// <summary> /// Validates that the given member name will yield a range validation exception when not in the valid range. /// </summary> private void ValidateRangeFieldValidation <T>(EventCounterTriggerSettings settings, string memberName, string min, string max) { RangeAttribute rangeAttribute = new(typeof(T), min, max); ValidateFieldValidation(settings, rangeAttribute.FormatErrorMessage(memberName), new[] { memberName }); }
/// <summary> /// Validates that the given member name will yield a requiredness validation exception when not specified. /// </summary> private void ValidateRequiredFieldValidation(EventCounterTriggerSettings settings, string memberName) { RequiredAttribute requiredAttribute = new(); ValidateFieldValidation(settings, requiredAttribute.FormatErrorMessage(memberName), new[] { memberName }); }