public void IsRequiredWithBlank() { SelectParameter parameter = new SelectParameter(); parameter.Name = "Test"; parameter.IsRequired = true; Exception[] results = parameter.Validate(string.Empty); Assert.AreEqual(1, results.Length, "Number of exceptions does not match"); Assert.AreEqual("Value of 'Test' is required", results[0].Message, "Exception message does not match"); }
public void IsAllowedValue() { SelectParameter parameter = new SelectParameter(); parameter.Name = "Test"; parameter.DataValues = new NameValuePair[] { new NameValuePair(string.Empty, "Dev"), new NameValuePair("Test", "Test"), new NameValuePair(null, "Prod") }; Exception[] results = parameter.Validate("Dev"); Assert.AreEqual(0, results.Length, "Number of exceptions does not match"); }
public void IsNotAllowedValue() { SelectParameter parameter = new SelectParameter(); parameter.Name = "Test"; parameter.DataValues = new NameValuePair[] { new NameValuePair(string.Empty, "Dev"), new NameValuePair("Test", "Test"), new NameValuePair(null, "Prod") }; Exception[] results = parameter.Validate("QA"); Assert.AreEqual(1, results.Length, "Number of exceptions does not match"); Assert.AreEqual("Value of 'Test' is not an allowed value", results[0].Message, "Exception message does not match"); }