Ejemplo n.º 1
0
        public async Task GivenExistFile_ReturnsOkCode()
        {
            var client = await _factory.GetAuthenticatedClientAsync();

            // Mock file
            var formData = _factory.MockUploadFileAction("file1.txt", "Test dataaaaaaaaaaaa");

            var response = await client.PostAsync($"/api/Upload/", formData);

            response.StatusCode.ShouldBe(HttpStatusCode.OK);

            var vm = await IntegrationTestHelper.GetResponseContent <FileListDto>(response);

            var blobUri = await _factory.GetService <IBlobStorageService>().UploadFileToBlobAsync(vm.Files[0].LocalUrl, vm.Files[0].FileStorageName);

            var downloadResponse = await client.GetAsync($"/api/Upload/DownloadFile/?fileUrl={blobUri}&name={"test.txt"}");

            downloadResponse.StatusCode.ShouldBe(HttpStatusCode.OK);
            await _factory.GetService <IBlobStorageService>().DeleteBlobData(blobUri);
        }
Ejemplo n.º 2
0
        public async Task GivenExistFile_ReturnsOkCode()
        {
            var client = await _factory.GetAuthenticatedClientAsync();

            //Setup mock file using a memory stream
            var data     = "Hello World from a Fake File";
            var fileName = "test.txt";
            var formData = _factory.MockUploadFileAction(fileName, data);

            var response = await client.PostAsync($"/api/Upload/", formData);

            response.StatusCode.ShouldBe(HttpStatusCode.OK);

            var vm = await IntegrationTestHelper.GetResponseContent <FileListDto>(response);

            var blobUri = await _factory.GetService <IBlobStorageService>().UploadFileToBlobAsync(vm.Files[0].LocalUrl, vm.Files[0].FileStorageName);

            var downloadResponse = await client.GetAsync($"/api/Upload/DownloadAllFile/?fileUrls={blobUri}&names={"test.txt"}");

            downloadResponse.StatusCode.ShouldBe(HttpStatusCode.OK);
            await _factory.GetService <IBlobStorageService>().DeleteBlobData(blobUri);
        }
Ejemplo n.º 3
0
 protected TService GetService <TService>() where TService : class
 {
     return(_factory.GetService <TService>());
 }