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 that the folder name's functions are correctly checked public void folderName() { Boolean result = true; // try to add an unexisting path result = _filenameManipulation.setFolder("Unexisting path"); Assert.AreEqual(false, result); Assert.AreEqual("", _filenameManipulation.getFolder()); // add an existing path result = _filenameManipulation.setFolder(_validFolder); Assert.AreEqual(true, result); Assert.AreEqual(_validFolder, _filenameManipulation.getFolder()); // change to a non-existing path. The previous path should have been kept result = _filenameManipulation.setFolder("unexisting folder"); Assert.AreEqual(false, result); Assert.AreEqual(_validFolder, _filenameManipulation.getFolder()); }