public void TestCopyWhiteSpaceStringDestination()
        {
            var connectClient = new LiveConnectClient(new LiveConnectSession());

            try
            {
                connectClient.CopyAsync("fileId.123", "\t\n ");
                Assert.Fail("Expected ArguementException to be thrown.");
            }
            catch (ArgumentException)
            {
            }
        }
        public void TestCopyNullDestination()
        {
            var connectClient = new LiveConnectClient(new LiveConnectSession());

            try
            {
                connectClient.CopyAsync("fileId.123", null);
                Assert.Fail("Expected ArguementNullException to be thrown.");
            }
            catch (ArgumentNullException)
            {
            }
        }
        public void TestCopyEmptyStringPath()
        {
            var connectClient = new LiveConnectClient(new LiveConnectSession());

            try
            {
                connectClient.CopyAsync(string.Empty, "fileId.123");
                Assert.Fail("Expected ArguementException to be thrown.");
            }
            catch (ArgumentException)
            {
            }
        }
Exemple #4
0
        private async void RunButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Validate parameters
                string path        = pathTextBox.Text;
                string destination = destinationTextBox.Text;
                string requestBody = requestBodyTextBox.Text;
                var    scope       = (authScopesComboBox.SelectedValue as ComboBoxItem).Content as string;
                var    method      = (methodsComboBox.SelectedValue as ComboBoxItem).Content as string;

                // acquire auth permissions
                var authClient = new LiveAuthClient();
                var authResult = await authClient.LoginAsync(new string[] { scope });

                if (authResult.Session == null)
                {
                    throw new InvalidOperationException("You need to login and give permission to the app.");
                }

                var liveConnectClient = new LiveConnectClient(authResult.Session);
                LiveOperationResult operationResult = null;
                switch (method)
                {
                case "GET":
                    operationResult = await liveConnectClient.GetAsync(path);

                    break;

                case "POST":
                    operationResult = await liveConnectClient.PostAsync(path, requestBody);

                    break;

                case "PUT":
                    operationResult = await liveConnectClient.PutAsync(path, requestBody);

                    break;

                case "DELETE":
                    operationResult = await liveConnectClient.DeleteAsync(path);

                    break;

                case "COPY":
                    operationResult = await liveConnectClient.CopyAsync(path, destination);

                    break;

                case "MOVE":
                    operationResult = await liveConnectClient.MoveAsync(path, destination);

                    break;
                }

                if (operationResult != null)
                {
                    Log("Operation succeeded: \r\n" + operationResult.RawResult);
                }
            }
            catch (Exception ex)
            {
                Log("Got error: " + ex.Message);
            }
        }
 public void TestCopyWhiteSpaceStringDestination()
 {
     var connectClient = new LiveConnectClient(new LiveConnectSession());
     try
     {
         connectClient.CopyAsync("fileId.123", "\t\n ");
         Assert.Fail("Expected ArguementException to be thrown.");
     }
     catch (ArgumentException)
     {
     }
 }
 public void TestCopyNullDestination()
 {
     var connectClient = new LiveConnectClient(new LiveConnectSession());
     try
     {
         connectClient.CopyAsync("fileId.123", null);
         Assert.Fail("Expected ArguementNullException to be thrown.");
     }
     catch (ArgumentNullException)
     {
     }
 }
 public void TestCopyEmptyStringPath()
 {
     var connectClient = new LiveConnectClient(new LiveConnectSession());
     try
     {
         connectClient.CopyAsync(string.Empty, "fileId.123");
         Assert.Fail("Expected ArguementException to be thrown.");
     }
     catch (ArgumentException)
     {
     }
 }