


#Iclipboard code
So I installed the System.IO.Abstractions NuGet package, and changed my code to support the IFileSystem (basically replaced all IO calls by appending in the beginning my new IFileSystem object calls). In the end the main problem is that you get to a File.Move or File.Copy - and so that's why I needed something to handle it. My PerformPaste still calls the sub-methods, but now they are all "Ok". PasteFromTree(targetFolder, moveNotCopy) PasteFromList(targetFolder, moveNotCopy) Įlse if (treeInternalUseCopy != null) // from tree If (listInternalUseCopy != null) // from list String targetFolder = GetTargetFolder(listPath, treePath) If (!PasteFromOutsideSucceeded(clipboardList, listPath)) My PerformPaste now looks like this: public bool PerformPaste(List listInternalUseCopy, string treeInternalUseCopy, StringCollection clipboardList, bool moveNotCopy, string listPath, string treePath) MessageBox.Show("Please select a destiantion.") Īnd the only thing I'm testing (atm) is _hadnler.PerformPaste.Īs you can see, I decided to ignore clipboard and other factors right now, and just focus on the FileSystem operations. Var result = _hadnler.PerformPaste(Globals.ListInternalUseCopy, Globals.TreeInternalUseCopy, list, MoveNotCopy, shellList.Path, shellTree.SelectedPath) My DoCtrlV now looks like this: StopWait() I passed to it in the constructor all the necessary objects it needed to run. I extracted all the testable code into a separate class, outside of the window code-behind were it resided before (really bad place to test things, as you need to instantiate the window to actually test).If (Globals.ListInternalUseCopy != null) // from listĮlse if (Globals.TreeInternalUseCopy != null) // from treeĮDIT/UPDATE: There were many things I had to do, and I'm still mid point, but this is what I did so far. I tried looking at tutorials and online courses but they are too abstract and couldn't really help me on my current issue. How do I begin writing unit tests to methods such as these, which require use of clipboard, and actual moving or coping of files in the file system? I have an explorer like component, which actually deals with the file system.
