Exemplo n.º 1
0
        public static void ClientRetrivesFileListContentsCorrectly()
        {
            var credentials = CredentialsProvider.Instance.GetCredentials();

            var httpClient = new ExHttpClient();
            var cookies = httpClient.GetCookiesAsync(credentials).Result;
            var apiClient = new ExClient();

            var firstFileId = apiClient.FileList(credentials, 0, 100).Result.Items.First().Id;

            var fileList = httpClient.GetObjectFileInfosAsync(firstFileId, cookies).Result;

            fileList.Should().NotBeEmpty();
        }
Exemplo n.º 2
0
        public static void Main()
        {
            var testFilePath = "..\\..\\..\\sample-content-for-upload.jpg";
          
            var apiClient = new ExClient();

            var uploder = new EXUAUploader.Uploader(apiClient);
            
            var configurationManager = ConfigurationManager.AppSettings;
            var login = configurationManager["login"];
            var password = configurationManager["password"];
            var objectId = long.Parse(configurationManager["test-object-id"]);

            var fileList = apiClient.FileList(new Credentials(login, password), 0, Int32.MaxValue).Result;

            uploder.UploadFileAsync(testFilePath, objectId, new Credentials(login, password)).Wait();
        }
Exemplo n.º 3
0
        public static void ClientPerformsFileDownloadCorrectly()
        {
            var credentials = CredentialsProvider.Instance.GetCredentials();

            var httpClient = new ExHttpClient();
            var cookies = httpClient.GetCookiesAsync(credentials).Result;
            var apiClient = new ExClient();

            var firstFileId = apiClient.FileList(credentials, 0, 100).Result.Items.First().Id;
            
            var fileInfo = httpClient.GetObjectFileInfosAsync(72195263, cookies).Result.Last();

            //for (int i = 0; i < 10; i++)
            {
            //    var downloadFirstChunk = httpClient.DownloadFileAsync(fileInfo, cookies: cookies).Result;
            }

          

           
        }
Exemplo n.º 4
0
        public static void WhenMultipleFilesAreCreated_TheySHouldBeDeletedProperly()
        {
            var credentials = CredentialsProvider.Instance.GetCredentials();

            var httpClient = new ExHttpClient();
            var cookies = httpClient.GetCookiesAsync(credentials).Result;

            var newIdsCollection = new Collection<long>();

            for (int i = 0; i < 2; i++)
            {
                httpClient.GetNewObjectUriAsync(cookies).ContinueWith(t =>
                {
                    var newId = long.Parse(t.Result.Segments.Last());
                    newIdsCollection.Add(newId);

                    httpClient.SaveObjectAsync(newId, "Test object #" + i, "Contents #" + i, cookies).Wait();
                    Debug.WriteLine("Created object #{0}", t.Result);

                }).Wait();
            }

            var apiClient = new ExClient();

            apiClient.FileList(credentials, 0, 100).ContinueWith(t =>
            {
                t.Result.Items.Select(it => it.Id).Should().Contain(newIdsCollection);
            }).Wait();

            foreach (long id in newIdsCollection)
            {
                httpClient.DeleteObjectAsync(id, cookies).Wait();
                Debug.WriteLine("Deleted object #{0}", id);
            }
            
            apiClient.FileList(credentials, 0, 100).ContinueWith(t =>
            {
                t.Result.Items.Select(it => it.Id).Should().NotContain(newIdsCollection);
            }).Wait();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            var credentials = CredentialsProvider.Instance.GetCredentials();

            var httpClient = new ExHttpClient();
            var cookies = httpClient.GetCookiesAsync(credentials).Result;
            var apiClient = new ExClient();

            var firstFileId = apiClient.FileList(credentials, 0, 100).Result.Items.First().Id;

            var fileInfo = httpClient.GetObjectFileInfosAsync(92489544, cookies).Result.Last();

            
           // var downloadFirstChunk = httpClient.DownloadFileAsync(fileInfo, cookies: cookies).Result;

           // var downloadTracker = new DownloadTracker(exBaseAddress: "http://www.ex.ua/");

          //  var cts = new CancellationTokenSource();

            //downloadTracker.StartOrResumeDownload(fileInfo, cts.Token).Wait();

            System.Console.ReadKey();
        }