public void ValidateResultTest()
        {
            ValidateResult validateResult = new Validater().Validate();
            ValidateFailException validateFailException = new ValidateFailException(validateResult);

            Assert.AreSame(validateResult, validateFailException.ValidateResult);
        }
Exemple #2
0
        public void NoValidateTest()
        {
            Validater validater = new Validater();

            ValidateResult validateResult = validater.Validate();
            Assert.IsTrue(validateResult.IsValidated);
            Assert.AreEqual<int>(0, validateResult.ErrorMessage.Length);
        }
Exemple #3
0
        public void ValidateFailWithMutipleErrorMessageTest()
        {
            Validater validater = new Validater()
                .AddCondition(false, new string[] { "Error2", "Error3" });

            ValidateResult validateResult = validater.Validate();
            Assert.IsFalse(validateResult.IsValidated);

            //Validate error message
            Assert.AreEqual<int>(2, validateResult.ErrorMessage.Length);
            Assert.AreEqual<string>("Error2", validateResult.ErrorMessage[0]);
            Assert.AreEqual<string>("Error3", validateResult.ErrorMessage[1]);
        }
Exemple #4
0
        public void ToSringTest()
        {
            Validater validater;
            ValidateResult validateResult;

            //验证通过
            validater = new Validater();
            validateResult = validater.Validate();
            Assert.AreEqual<string>("验证通过", validateResult.ToString());
            Assert.AreEqual<string>("验证通过", validater.ToString());

            //验证失败
            validater = new Validater();
            validater.AddCondition(false, "Error1");
            validater.AddCondition(false, "Error2");
            validateResult = validater.Validate();
            Assert.AreEqual<string>("验证失败:\r\nError1\r\nError2\r\n", validateResult.ToString());
            Assert.AreEqual<string>("验证失败:\r\nError1\r\nError2\r\n", validater.ToString());
        }
Exemple #5
0
        public void ValidatePassTest()
        {
            Validater validater = new Validater()
                .AddCondition(true, "Error");

            ValidateResult validateResult = validater.Validate();
            Assert.IsTrue(validateResult.IsValidated);
            Assert.AreEqual<int>(0, validateResult.ErrorMessage.Length);
        }