コード例 #1
0
        public void IsValidCompareDifferentTypes()
        {
            NotEqualToValidator notEqualToValidator = new NotEqualToValidator(10);

            Assert.IsTrue(notEqualToValidator.IsValid(10M));
            Assert.IsTrue(notEqualToValidator.IsValid("10"));
        }
コード例 #2
0
        public void IsValidCompareIntegerValue()
        {
            NotEqualToValidator notEqualToValidator = new NotEqualToValidator(10);

            Assert.IsFalse(notEqualToValidator.IsValid(10));
            Assert.IsTrue(notEqualToValidator.IsValid(1));
        }
コード例 #3
0
        public void IsValidCompareStringWithOrdinalIgnoreCaseComparer()
        {
            NotEqualToValidator notEqualToValidator = new NotEqualToValidator("TEST", StringComparer.OrdinalIgnoreCase);

            Assert.IsFalse(notEqualToValidator.IsValid("test"));
            Assert.IsFalse(notEqualToValidator.IsValid("TEST"));
        }
コード例 #4
0
        public void IsValidCompareString()
        {
            NotEqualToValidator notEqualToValidator = new NotEqualToValidator("TEST");

            Assert.IsTrue(notEqualToValidator.IsValid("test"));
            Assert.IsTrue(notEqualToValidator.IsValid("Test"));
            Assert.IsFalse(notEqualToValidator.IsValid("TEST"));
        }
コード例 #5
0
        public void GetValidator()
        {
            const string                  valueToCompare = "TEST";
            IEqualityComparer             comparer       = StringComparer.OrdinalIgnoreCase;
            NotEqualToValidationAttribute notEqualToValidationAttribute = new NotEqualToValidationAttribute(valueToCompare, comparer);

            Assert.IsInstanceOf(typeof(NotEqualToValidator), notEqualToValidationAttribute.GetValidator());

            NotEqualToValidator notEqualToValidator = (NotEqualToValidator)notEqualToValidationAttribute.GetValidator();

            Assert.AreEqual(valueToCompare, notEqualToValidator.ValueToCompare);
            Assert.AreEqual(comparer, notEqualToValidator.Comparer);
        }
コード例 #6
0
        public void IsValidCompareNullValue()
        {
            NotEqualToValidator notEqualToValidator = new NotEqualToValidator(string.Empty);

            Assert.IsTrue(notEqualToValidator.IsValid(null));
        }
コード例 #7
0
        public void IsValidCompareEmptyString()
        {
            NotEqualToValidator notEqualToValidator = new NotEqualToValidator(string.Empty);

            Assert.IsFalse(notEqualToValidator.IsValid(string.Empty));
        }