| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| using Google.Apis.Json; |
| using Google.Apis.Services; |
| using Google.Apis.Tests.Mocks; |
| using Google.Apis.Upload; |
| using Google.Apis.Util; |
| using System; |
| using System.Collections.Concurrent; |
| using System.Collections.Generic; |
| using System.Collections.Specialized; |
| using System.IO; |
| using System.Linq; |
| using System.Net; |
| using System.Net.Http; |
| using System.Net.Sockets; |
| using System.Text; |
| using System.Threading; |
| using System.Threading.Tasks; |
| using Xunit; |
| using Xunit.Abstractions; |
|
|
| namespace Google.Apis.Tests.Apis.Upload |
| { |
| |
| |
| |
| public partial class ResumableUploadTest : IDisposable |
| { |
| |
| |
| |
| |
| |
| private static readonly string UploadTestData = |
| "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod " + |
| "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris " + |
| "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore " + |
| "eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit " + |
| "anim id est laborum."; |
| private static readonly byte[] UploadTestBytes = Encoding.UTF8.GetBytes(UploadTestData); |
| private static readonly int UploadLength = UploadTestBytes.Length; |
|
|
| |
| |
| |
| private const string UploadPath = "resume"; |
|
|
| private readonly TestServer _server; |
| private readonly TestLogger _logger; |
|
|
| public ResumableUploadTest(ITestOutputHelper outputHelper) |
| { |
| _logger = new TestLogger(outputHelper); |
| _logger.WriteLine("Start of test"); |
| _server = new TestServer(_logger); |
| } |
|
|
| public void Dispose() |
| { |
| _server.Dispose(); |
| _logger.WriteLine("Test disposed"); |
| } |
|
|
| |
| |
| |
| [Fact] |
| public void TestChunkSize() |
| { |
| using (var service = new MockClientService(new BaseClientService.Initializer())) |
| { |
| var stream = new MemoryStream(Encoding.UTF8.GetBytes(UploadTestData)); |
| var upload = new TestResumableUpload(service, "whatever", "POST", stream, "text/plain", 100); |
|
|
| |
| Assert.Throws<ArgumentOutOfRangeException>(() => upload.ChunkSize = -1); |
| |
| Assert.Throws<ArgumentOutOfRangeException>(() => upload.ChunkSize = ResumableUpload.MinimumChunkSize - 1); |
| |
| upload.ChunkSize = ResumableUpload.MinimumChunkSize; |
| upload.ChunkSize = ResumableUpload.MinimumChunkSize * 2; |
| } |
| } |
| } |
| } |
|
|