Esempio n. 1
0
        public void TestValidateFileName()
        {
            Assert.IsTrue(BaseFile.ValidateFileName("MyFile"), "name only contains letters and should be valid");
            Assert.IsTrue(BaseFile.ValidateFileName("My1_2File/123"), "name only contains letters, numbers and / and \\ and should be valid");
            Assert.IsTrue(BaseFile.ValidateFileName("My1_2File/1\\fshjkfs"), "name has 2 pairs of / or \\ and should be valid");

            Assert.IsFalse(BaseFile.ValidateFileName("!nvalidname"), "name contains invalid symbol and shouldn't be valid");
            Assert.IsFalse(BaseFile.ValidateFileName("invalid name"), "name contains space and shouldn't be valid");
            Assert.IsFalse(BaseFile.ValidateFileName("invalidname/"), "name ends in a / and shouldn't be valid");
            Assert.IsFalse(BaseFile.ValidateFileName("invalid//name"), "name contains 2 / after each other and shouldn't be valid");
        }