Example #1
0
        private static async Task DeleteObjectAsync(long objectId, Credentials credentials)
        {
            var httpClient = new ExHttpClient();
            var cookies = httpClient.GetCookiesAsync(credentials).Result;

            await httpClient.DeleteObjectAsync(objectId, cookies);

            Debug.WriteLine("Deleted object #{0}", objectId);
        }
Example #2
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();
        }
Example #3
0
        private static async Task<long> GetNewObjectIdAsync(Credentials credentials)
        {
            var httpClient = new ExHttpClient();
            var cookies = httpClient.GetCookiesAsync(credentials).Result;

            var url = await httpClient.GetNewObjectUriAsync(cookies);

            long newId = long.Parse(url.Segments.Last());

            await httpClient.SaveObjectAsync(newId, "Test object created", "test content", cookies);
            
            Debug.WriteLine("Created object #{0}", newId);

            return await Task.FromResult(newId);
        }
Example #4
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;
            }

          

           
        }
Example #5
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();
        }
Example #6
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();
        }