public FieldValidation ToAPIFieldValidation() { if (fieldValidator == null) { return fieldValidation; } fieldValidation = new Silanis.ESL.API.FieldValidation(); fieldValidation.MaxLength = fieldValidator.MaxLength; fieldValidation.MinLength = fieldValidator.MinLength; fieldValidation.Required = fieldValidator.Required; fieldValidation.ErrorMessage = fieldValidator.Message; fieldValidation.ErrorCode = fieldValidator.ErrorCode; if (!String.IsNullOrEmpty(fieldValidator.Regex)) { fieldValidation.Pattern = fieldValidator.Regex; } if (fieldValidator.Options != null && fieldValidator.Options.Count != 0) { foreach (String option in fieldValidator.Options) { fieldValidation.AddEnum(option); } } return fieldValidation; }
public void ConvertAPIToAPI() { apiFieldValidation1 = CreateTypicalAPIFieldValidation(); FieldValidatorConverter converter = new FieldValidatorConverter(apiFieldValidation1); apiFieldValidation2 = converter.ToAPIFieldValidation(); Assert.IsNotNull(apiFieldValidation2); Assert.AreEqual(apiFieldValidation2, apiFieldValidation1); }
public void ConvertAPIToSDK() { apiFieldValidation1 = CreateTypicalAPIFieldValidation(); sdkFieldValidator1 = new FieldValidatorConverter(apiFieldValidation1).ToSDKFieldValidator(); Assert.AreEqual(sdkFieldValidator1.Message, apiFieldValidation1.ErrorMessage); Assert.AreEqual(sdkFieldValidator1.MaxLength, apiFieldValidation1.MaxLength); Assert.AreEqual(sdkFieldValidator1.MinLength, apiFieldValidation1.MinLength); Assert.AreEqual(sdkFieldValidator1.Required, apiFieldValidation1.Required); Assert.IsEmpty(sdkFieldValidator1.Options); }
public void ConvertSDKToAPI() { sdkFieldValidator1 = CreateTypicalSDKValidator(); apiFieldValidation1 = new FieldValidatorConverter(sdkFieldValidator1).ToAPIFieldValidation(); Assert.AreEqual(apiFieldValidation1.ErrorCode, 150); Assert.AreEqual(apiFieldValidation1.ErrorMessage, sdkFieldValidator1.Message); Assert.AreEqual(apiFieldValidation1.MaxLength, sdkFieldValidator1.MaxLength); Assert.AreEqual(apiFieldValidation1.MinLength, sdkFieldValidator1.MinLength); Assert.AreEqual(apiFieldValidation1.Required, sdkFieldValidator1.Required); Assert.AreEqual(apiFieldValidation1.Pattern, sdkFieldValidator1.Regex); }
public FieldValidatorConverter(FieldValidation fieldValidation) { this.fieldValidation = fieldValidation; fieldValidator = null; }
public FieldValidatorConverter(FieldValidator fieldValidator) { this.fieldValidator = fieldValidator; fieldValidation = null; }
private FieldValidation CreateTypicalAPIFieldValidation() { FieldValidation apiFieldValidation = new FieldValidation(); apiFieldValidation.ErrorCode = 100; apiFieldValidation.ErrorMessage = "Error message."; apiFieldValidation.MaxLength = 30; apiFieldValidation.MinLength = 10; apiFieldValidation.Pattern = "*pattern*"; apiFieldValidation.Required = true; return apiFieldValidation; }
public void ConvertNullAPIToAPI() { apiFieldValidation1 = null; FieldValidatorConverter converter = new FieldValidatorConverter(apiFieldValidation1); Assert.IsNull(converter.ToAPIFieldValidation()); }