Beispiel #1
0
        public void IsValidFail(IComparable value, IComparable comparedValue, bool expected)
        {
            var attribute = new CannotBeEqualToAttribute(comparedValue);

            try
            {
                attribute.IsValid(value);

                Assert.Fail();
            }
            catch (FormatException ex)
            {
                Assert.AreEqual("Input string was not in a correct format.", ex.Message);
            }
        }
Beispiel #2
0
        public void IsValid2()
        {
            var attribute = new CannotBeEqualToAttribute(5);

            Assert.AreEqual(!false, attribute.IsValid(null));
            Assert.AreEqual(!false, attribute.IsValid(DBNull.Value));

            attribute = new CannotBeEqualToAttribute(null);

            Assert.AreEqual(!false, attribute.IsValid(5));
            Assert.AreEqual(!true, attribute.IsValid(null));
            Assert.AreEqual(!false, attribute.IsValid(DBNull.Value));

            attribute = new CannotBeEqualToAttribute(DBNull.Value);

            Assert.AreEqual(!false, attribute.IsValid(5));
            Assert.AreEqual(!false, attribute.IsValid(null));
            Assert.AreEqual(!true, attribute.IsValid(DBNull.Value));
        }
Beispiel #3
0
        public void IsValid(IComparable value, IComparable comparedValue, bool expected)
        {
            var attribute = new CannotBeEqualToAttribute(comparedValue);

            Assert.AreEqual(expected, attribute.IsValid(value));
        }