Create the SUnit test to validate the code we intend to write

Our goal is to write new capability in FileList to copy selected files. The files we want to copy can exist locally or on a remote system. We'll assume for now that we will always copy the file to a local system.

We should test for the copying of a file from a local file system and from a remote file system. In both cases the approach should be that we will create a local temporary directory where we will create the new copied files, and we will create temporary unique files on both the local and remote system which we will use as the source of our copy operations. After a file is copied we can check that it exists and that it has the proper contents. Upon testing completion we should remove our temporary files and temporary directory.

Open up a Browser on the FileListTest class. Let's build up some additional support mehods. First, select the #createTempFile method. Let's change it by making a new method where we can pass in the directory we want to use.

createTempFileIn: aDirectory
     | time fname fstream |
     time := Time now.
     fname := time hhmm24 , time seconds printString , '.tmp'.
     (aDirectory fileExists: fname)
         ifTrue: [ aDirectory deleteFileNamed: fname].
     fstream := aDirectory forceNewFileNamed: fname.
     fstream nextPutAll: self tempFileContents.
     fstream close.
     ^ fname

Select the old #createTempFile method again and find all senders. We changed the signature of the method as well as the object returned. So the only sender (#testFileNameOperations) will need to be modified this way:


We can now safely delete the old method #createTempFile. In the Browser, select it and pick "remove method" from the methods menu. Note: Squeak would have complained to us if we would have tried to remove the method without deleting references in it's senders.

Continue on to the next page of second FileList enhancement.

Back to the beginning of this example.