views:

808

answers:

1

I have (after quite a bit of work) a web test that will upload a file to my SharePoint document library using a file that is included in the test and DeploymentItem that identifies that file so it can be used in the file upload post parameter.

That works great, now ignoring the SharePoint factor for a moment, image that I want to run the webtest as part of a loadtest. That means that the file upload test needs to be run a fair amount of times. That is not so great if I am upload the same file to the same filename all the time.

What I want to do is to create a random file at the target, using the same file data. e.g. I want the file that is uploaded to have the filename "image1" + Guid.NewGuid.ToString() + ".jpg".

Aside from creating a new file on the disc with that name and adding a Deployment item or something to locate the file each time, I am at a loss as how to do this. This is especially a problem as the web test will be run via a test agent on a machine that I will not really be able to create that much code on.

Worst case scenario I will go with deleteing the file after uploading it.

Any ideas on how I can do this?

A: 

given a scenarion where the file image1.jpg is being set as the deployment item and is being copied to the build target, the following code creates a file available for upload in the manner required

string image1Location = "image1" + Guid.NewGuid().ToString() + ".jpg"
 System.IO.File.Copy("image1.jpg", image1Location);

after the file has been used

System.IO.File.Delete(image1Location)
Nat