Creating a Visual Studio web test to upload a file with a random file name

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

This works fine, now ignoring the SharePoint factor for a moment, the image I want to run a web test as part of the loadtest. This means that the file upload test should run quite a few times. It’s not so great if I upload the same file to the same file name all the time.

What I want to do is create a random file in the target using the same file data. for example, I want the file to be downloaded in order to have the file name "image1" + Guid.NewGuid.ToString () + ".jpg".

Besides creating a new file on disk with this name and adding a deployment item or something to find the file every time, I don’t understand how to do it. This is especially a problem, since the web test will run through the test agent on a machine on which I really cannot create such code.

In the worst case, I will go with deleting the file after downloading it.

Any ideas on how I can do this?

+3
source share
1 answer

, image1.jpg , , ,

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

,

System.IO.File.Delete(image1Location)
+1

Source: https://habr.com/ru/post/1699175/


All Articles