Ejemplo n.º 1
0
        public void IsValid()
        {
            var attribute = new MustBeValidFilePathAttribute();

            Assert.AreEqual(true, attribute.IsValid(null));
            Assert.AreEqual(true, attribute.IsValid(DBNull.Value));
            Assert.AreEqual(false, attribute.IsValid(string.Empty));
            Assert.AreEqual(false, attribute.IsValid(" "));
            Assert.AreEqual(true, attribute.IsValid("abc.txt"));
            Assert.AreEqual(true, attribute.IsValid(@"C:\Windows\tmp\file.txt"));
            Assert.AreEqual(false, attribute.IsValid(@"C:\Wi|ndows\tmp"));
        }
Ejemplo n.º 2
0
        public void IsValidFail(object value)
        {
            var attribute = new MustBeValidFilePathAttribute();

            try
            {
                attribute.IsValid(value);

                Assert.Fail();
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("Value must be of type String.", ex.Message);
            }
        }