public void DownloadFileAsyncSucceedsForValidUrl() { var buildEngine = new MockBuildEngine(); var publishTask = new PublishArtifactsInManifestV3 { BuildEngine = buildEngine, }; var testFile = Path.Combine("Symbols", "test.txt"); var responseContent = TestInputs.ReadAllBytes(testFile); var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(responseContent) }; using HttpClient client = FakeHttpClient.WithResponses(response); var path = TestInputs.GetFullPath(Guid.NewGuid().ToString()); var test = publishTask.DownloadFileAsync( client, PublishArtifactsInManifestBase.ArtifactName.BlobArtifacts, "1234", "test.txt", path); Assert.True(File.Exists(path)); publishTask.DeleteTemporaryFiles(path); publishTask.DeleteTemporaryDirectory(path); }
public void TemporarySymbolsDirectoryTest() { var buildEngine = new MockBuildEngine(); var publishTask = new PublishArtifactsInManifestV3() { BuildEngine = buildEngine, }; var path = TestInputs.GetFullPath("Test"); publishTask.EnsureTemporaryDirectoryExists(path); Assert.True(Directory.Exists(path)); publishTask.DeleteTemporaryDirectory(path); Assert.False(Directory.Exists(path)); }
public async Task DownloadFileSuccessfulAfterRetryTest(HttpStatusCode httpStatus) { var buildEngine = new MockBuildEngine(); var publishTask = new PublishArtifactsInManifestV3 { BuildEngine = buildEngine, }; var testFile = Path.Combine("Symbols", "test.txt"); var responseContent = TestInputs.ReadAllBytes(testFile); publishTask.RetryHandler = new ExponentialRetry() { MaxAttempts = 2, DelayBase = 1 }; var responses = new[] { new HttpResponseMessage(httpStatus) { Content = new ByteArrayContent(responseContent) }, new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(responseContent) } }; using HttpClient client = FakeHttpClient.WithResponses(responses); var path = TestInputs.GetFullPath(Guid.NewGuid().ToString()); await publishTask.DownloadFileAsync( client, PublishArtifactsInManifestBase.ArtifactName.BlobArtifacts, "1234", "test.txt", path); Assert.True(File.Exists(path)); publishTask.DeleteTemporaryFiles(path); publishTask.DeleteTemporaryDirectory(path); }