/// <summary> /// Validate API request input dto. /// </summary> /// <typeparam name="TRequest"></typeparam> /// <param name="request">request input.</param> /// <returns>ValidationResult</returns> private ValidationResult ValidateRequestDto <TRequest>(BaseRequestDto <TRequest> request) { ValidationResult results = new ValidationResult(); IValidator <BaseRequestDto <TRequest> > baseValidator = new BaseRequestValidator <TRequest>(); results = baseValidator.Validate(request); if (results.IsValid) { Type customValidator = System.Reflection.Assembly.Load(typeof(TRequest).Assembly.GetName()).GetTypes().Where(x => x.IsSubclassOf(typeof(AbstractValidator <TRequest>))).FirstOrDefault(); if (customValidator != null) { IValidator <TRequest> innerDataValidator = (IValidator <TRequest>)Activator.CreateInstance(customValidator); results = innerDataValidator.Validate(request.Data); } } return(results); }
[InlineData("-asd")] //Must not start with hyphen public void DnsLabelFailTest(string input) { Assert.False(BaseRequestValidator <GetObjectRequest> .BeValidDns(input)); }
public void DnsLabelSuccessTest(string input) { Assert.True(BaseRequestValidator <GetObjectRequest> .BeValidDns(input)); }