public void IsValid_Null_True() { var attr = new AllowedValuesAttribute("DE", "FR", "GB"); var act = attr.IsValid(null); Assert.IsTrue(act); }
public void IsValid_GB_True() { var attr = new AllowedValuesAttribute("DE", "FR", "GB"); var act = attr.IsValid(Country.GB); Assert.IsTrue(act); }
public void IsValid_TR_False() { var attr = new AllowedValuesAttribute("DE", "FR", "GB"); var act = attr.IsValid(Country.TR); Assert.IsFalse(act); }
public void IsValid_Fail_Test(object value) { var attribute = new AllowedValuesAttribute("5", "test2") { AllowNull = false }; Assert.False(attribute.IsValid(value)); }
public void IsValid_Exception_Test(object value) { var attribute = new AllowedValuesAttribute("5", "test2") { AllowNull = false }; Assert.Throws <ArgumentException>(() => attribute.IsValid(value)); }
public void IsValid_Success_Test(object value) { var attribute = new AllowedValuesAttribute("test1", "test2") { AllowNull = true }; Assert.True(attribute.IsValid(value)); }
public void AllowedValuesSetValidateEmptyOrWhitespaceStringNotAllowed(string valueToValidate) { AllowedValuesAttribute ava = new AllowedValuesAttribute(allowedValues: new string[] { "ptv", "vrk" }); ava.IsValid(valueToValidate).Should().BeFalse(); }
public void AllowedValuesDefined(string valueToValidate) { AllowedValuesAttribute ava = new AllowedValuesAttribute(allowedValues: new string[] { "", " ", "ptv", "something else" }); ava.IsValid(string.Empty).Should().BeTrue(); }
public void AllowedListEmptyNothingShouldBeValid(string valueToValidate) { AllowedValuesAttribute ava = new AllowedValuesAttribute(allowedValues: new string[] { }); ava.IsValid(valueToValidate).Should().BeFalse(); }
public void NullValueAlwaysAllowed() { AllowedValuesAttribute ava = new AllowedValuesAttribute(allowedValues: new string[] { "ptv", "vrk" }); ava.IsValid(null).Should().BeTrue(); }
public void NullAllowedEmptyAllowedList() { AllowedValuesAttribute ava = new AllowedValuesAttribute(allowedValues: new string[] { }); ava.IsValid(null).Should().BeTrue(); }
public void AllowedValuesSetValidateCaseSensitivity(string valueToValidate) { AllowedValuesAttribute ava = new AllowedValuesAttribute(allowedValues: new string[] { "ptv", "vrk" }); ava.IsValid(valueToValidate).Should().BeFalse(); }