Exemple #1
0
        public bool ConfigureFileManager(string path)
        {
            //get the filename
            string filename  = path.Split(new char[] { '\\' }).Last();
            string extension = path.Split(new char[] { '.' }).Last();
            string name      = filename.Replace("." + extension, "");

            //get the foldername to populate the listbox
            string foldername = path.Replace(filename, "");

            fm.setFolder(foldername);
            fm.setFileName(name);
            fm.setFileFilter(string.Empty);
            fm.setFileToken(string.Empty);
            fm.setFormat("." + extension);
            return(true);
        }
        [TestMethod] // control the file token's methods
        public void fileToken()
        {
            Boolean result     = true;
            String  validToken = " (filter) ";

            // try to set an invalid file token
            result = _filenameManipulation.setFileToken(" / ");
            Assert.AreEqual(false, result);
            Assert.AreEqual(" - ", _filenameManipulation.getFileToken());

            // set a valid file token
            result = _filenameManipulation.setFileToken(validToken);
            Assert.AreEqual(true, result);
            Assert.AreEqual(validToken, _filenameManipulation.getFileToken());

            // set invalid token, previous token should stay
            result = _filenameManipulation.setFileToken(" :filter: ");
            Assert.AreEqual(false, result);
            Assert.AreEqual(validToken, _filenameManipulation.getFileToken());
        }