Inheritance: IDisposable
示例#1
0
        public void CanAbortUploadWithCancellationToken()
        {
            var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));

            try
            {
                Task.Run(() =>
                {
                    using (var session = OpenSession())
                        using (var localFile = new DummyFile(52428800 /* 50mb */))
                        {
                            try
                            {
                                session.UploadFile(localFile.FileInfo, cancellationToken: cts.Token);
                            }
                            catch (AggregateException ex)
                            {
                                ex.Handle(x => x is OperationCanceledException);
                            }
                        }
                }, cts.Token).Wait();
            }
            catch (AggregateException ex)
            {
                ex.Flatten().Handle(x => x is OperationCanceledException);
            }
        }
示例#2
0
 public void CanUploadBigFile()
 {
     using (var session = OpenSession())
         using (var localFile = new DummyFile(52428800 /*50mb*/))
         {
             session.UploadFile(localFile.FileInfo);
             Assert.True(session.FileExists(localFile.FileInfo.Name));
         }
 }
示例#3
0
        public void CallingAbortOnUploadThrows()
        {
            using (var session = OpenSession())
            {
                Task.Delay(TimeSpan.FromSeconds(5))
                .ContinueWith(t => session.Abort());

                using (var localFile = new DummyFile(52428800 /* 50mb */))
                    session.UploadFile(localFile.FileInfo);
            }
        }
示例#4
0
        public void CanUploadFiles()
        {
            using (var session = OpenSession())
            {
                var localFiles = DummyFile.Generate().Take(3).ToArray();

                foreach (var localFile in localFiles)
                {
                    session.UploadFile(localFile.FileInfo);
                    Assert.True(session.FileExists(localFile.FileInfo.Name));
                }
                localFiles.Dispose();
            }
        }
示例#5
0
        public void CanUploadFilesIntoDeepSubDirectories()
        {
            using (var session = OpenSession())
            {
                var localFiles = DummyFile.Generate().Take(3).ToArray();

                foreach (var localFile in localFiles)
                {
                    session.UploadFile(localFile.FileInfo, remoteDirectoryPath: "cheech/chong/marvin/gaye/");
                    Assert.True(session.FileExists(string.Format("/cheech/chong/marvin/gaye/{0}", localFile.FileInfo.Name)));
                }
                localFiles.Dispose();
            }
        }
示例#6
0
        public void CanUploadFilesIntoSubDirectoryWithAnyPrePostSlashes()
        {
            using (var session = OpenSession())
            {
                var localFiles = DummyFile.Generate().Take(3).ToArray();

                foreach (var localFile in localFiles)
                {
                    session.UploadFile(localFile.FileInfo, remoteDirectoryPath: "/desktop\\");
                    Assert.True(session.FileExists(string.Format("/desktop/{0}", localFile.FileInfo.Name)));
                }

                localFiles.Dispose();
            }
        }
示例#7
0
        public void CanUploadFilesIntoSubDirectory()
        {
            using (var session = OpenSession())
            {
                var localFiles = DummyFile.Generate().Take(3).ToArray();

                foreach (var localFile in localFiles)
                {
                    session.UploadFile(localFile.FileInfo, remoteDirectoryPath: "desktop");
                    Assert.True(session.FileExists("/desktop/" + localFile.FileInfo.Name));
                }

                localFiles.Dispose();
            }
        }
示例#8
0
        public void CanUploadFilesDifferentNames()
        {
            using (var session = OpenSession())
            {
                var localFiles = DummyFile.Generate().Take(1).ToArray();

                foreach (var localFile in localFiles)
                {
                    var remoteFileName = "goober.dat";
                    session.UploadFile(localFile.FileInfo, remoteFileName);
                    Assert.True(session.FileExists(remoteFileName));
                }
                localFiles.Dispose();
            }
        }
        public void CallingAbortOnUploadThrows()
        {
            using (var session = OpenSession())
            {
                Task.Delay(TimeSpan.FromSeconds(5))
                    .ContinueWith(t => session.Abort());

                using (var localFile = new DummyFile(52428800 /* 50mb */))
                    session.UploadFile(localFile.FileInfo);
            }
        }
示例#10
0
        public void CanAbortUploadWithCancellationToken()
        {
            var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));

            try
            {
                Task.Run(() =>
                     {
                         using (var session = OpenSession())
                         using (var localFile = new DummyFile(52428800 /* 50mb */))
                         {
                             try
                             {
                                 session.UploadFile(localFile.FileInfo, cancellationToken: cts.Token);
                             }
                             catch (AggregateException ex)
                             {
                                 ex.Handle(x => x is OperationCanceledException);
                             }
                         }
                     }, cts.Token).Wait();
            }
            catch (AggregateException ex)
            {
                ex.Flatten().Handle(x => x is OperationCanceledException);
            }
        }
示例#11
0
 public void CanUploadBigFile()
 {
     using (var session = OpenSession())
     using (var localFile = new DummyFile(52428800 /*50mb*/))
     {
         session.UploadFile(localFile.FileInfo);
         Assert.True(session.FileExists(localFile.FileInfo.Name));
     }
 }