Пример #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);
        }
Пример #2
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();
        }