public void TestStringSchemaMinMaxLengthValid() { StringSchema schema = new StringSchema { MinLength = 2, MaxLength = 5 }; schema.Validate("12"); schema.Validate("123"); schema.Validate("1234"); schema.Validate("12345"); }
public void TestStringSchemaMinMaxLengthInvalidMax() { StringSchema schema = new StringSchema { MinLength = 2, MaxLength = 5 }; schema.Validate("12"); schema.Validate("123"); schema.Validate("1234"); schema.Validate("12345"); Assert.Throws <PropertyValidationException>(() => { schema.Validate("123456"); }); }
public void TestStringSchemaMinLengthInvalidEmpty() { StringSchema schema = new StringSchema { MinLength = 2 }; Assert.Throws <PropertyValidationException>(() => { schema.Validate(string.Empty); }); }
public void TestStringSchemaSetInvalidValueType() { StringSchema schema = new StringSchema(); Assert.Throws <PropertyValidationException>(() => { schema.Validate(1); }); }
public void TestStringSchemaAllowNull() { StringSchema schema = new StringSchema { AllowNull = true }; schema.Validate(null); }
public void TestStringSchemaAllowedValuesValid() { StringSchema schema = new StringSchema { PossibleValues = new[] { "one", "two", "three", "four" } }; schema.Validate("three"); }
public void TestStringSchemaNoNullAllowed() { StringSchema schema = new StringSchema { AllowNull = false }; Assert.Throws <PropertyValidationException>(() => { schema.Validate(null); }); }
public void TestStringSchemaAllowedValuesInvalid() { StringSchema schema = new StringSchema { PossibleValues = new[] { "one", "two", "three", "four" } }; Assert.Throws <PropertyValidationException>(() => { schema.Validate("five"); }); }
public void TestStringSchemaMaxLengthValid() { StringSchema schema = new StringSchema { MaxLength = 5 }; schema.Validate(string.Empty); schema.Validate("1"); schema.Validate("12"); schema.Validate("123"); schema.Validate("1234"); schema.Validate("12345"); }
public void TestStringSchemaValidValue() { StringSchema schema = new StringSchema(); schema.Validate("hello"); }