コード例 #1
0
        public void ValueIsNumeric()
        {
            NumericParameter parameter = new NumericParameter();

            parameter.Name = "Test";
            Exception[] results = parameter.Validate("Test");
            Assert.AreEqual(1, results.Length, "Number of exceptions does not match");
            Assert.AreEqual("Value of 'Test' is not numeric", results[0].Message, "Exception message does not match");
        }
コード例 #2
0
        public void ValueWithinValueRange()
        {
            NumericParameter parameter = new NumericParameter();

            parameter.Name         = "Test";
            parameter.MinimumValue = 0;
            parameter.MaximumValue = 100;
            Exception[] results = parameter.Validate("50");
            Assert.AreEqual(0, results.Length, "Number of exceptions does not match");
        }
コード例 #3
0
        public void IsRequiredWithBlank()
        {
            NumericParameter parameter = new NumericParameter();

            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");
        }
コード例 #4
0
        public void ValueAboveValueRange()
        {
            NumericParameter parameter = new NumericParameter();

            parameter.Name         = "Test";
            parameter.MinimumValue = 0;
            parameter.MaximumValue = 25;
            Exception[] results = parameter.Validate("50");
            Assert.AreEqual(1, results.Length, "Number of exceptions does not match");
            Assert.AreEqual("Value of 'Test' is more than the maximum allowed (25)", results[0].Message, "Exception message does not match");
        }