public async Task PutFileScenarioTest(string shareName, string fileName, FileProperties properties, byte[] content, HttpStatusCode?expectedError) { HttpRequestMessage request = FileTests.PutFileRequest(FileContext, shareName, fileName, properties, content, content.Length, null); request.Content = new ByteArrayContent(content); Assert.IsTrue(request != null, "Failed to create HttpRequestMessage"); //HttpRequestHandler.SetContentLength(request, content.Length); HttpResponseMessage response = await FileTestUtils.GetResponse(request, FileContext); try { FileTests.PutFileResponse(response, FileContext, expectedError); } finally { response.Dispose(); } }
public async Task CreateFile(string shareName, string fileName, bool isPublic) { Properties = new FileProperties(); HttpRequestMessage request = FileTests.PutFileRequest(FileContext, shareName, fileName, Properties, Content, 7000, null); Assert.IsTrue(request != null, "Failed to create HttpRequestMessage"); CancellationTokenSource timeout = new CancellationTokenSource(30000); HttpResponseMessage response = await FileTestUtils.GetResponse(request, FileContext, timeout); HttpStatusCode statusCode = response.StatusCode; string statusDescription = response.ReasonPhrase; response.Dispose(); if (statusCode != HttpStatusCode.Created) { Assert.Fail(string.Format("Failed to create file: {0}, Status: {1}, Status Description: {2}", shareName, statusCode, statusDescription)); } }
public void PutFileScenarioTest(string shareName, string fileName, FileProperties properties, byte[] content, HttpStatusCode?expectedError) { HttpWebRequest request = FileTests.PutFileRequest(FileContext, shareName, fileName, properties, content, content.Length, null); Assert.IsTrue(request != null, "Failed to create HttpWebRequest"); request.ContentLength = content.Length; if (FileContext.Credentials != null) { FileTests.SignRequest(request, FileContext); } FileTestUtils.SetRequest(request, FileContext, content); HttpWebResponse response = FileTestUtils.GetResponse(request, FileContext); try { FileTests.PutFileResponse(response, FileContext, expectedError); } finally { response.Close(); } }
public void CreateFile(string shareName, string fileName, bool isPublic) { Properties = new FileProperties(); HttpWebRequest request = FileTests.PutFileRequest(FileContext, shareName, fileName, Properties, Content, 7000, null); Assert.IsTrue(request != null, "Failed to create HttpWebRequest"); request.Timeout = 30000; if (FileContext.Credentials != null) { FileTests.SignRequest(request, FileContext); } HttpWebResponse response = FileTestUtils.GetResponse(request, FileContext); HttpStatusCode statusCode = response.StatusCode; string statusDescription = response.StatusDescription; response.Close(); if (statusCode != HttpStatusCode.Created) { Assert.Fail(string.Format("Failed to create file: {0}, Status: {1}, Status Description: {2}", shareName, statusCode, statusDescription)); } }