public void TestMoveNullDestination() { var connectClient = new LiveConnectClient(new LiveConnectSession()); try { connectClient.MoveAsync("fileId.123", null); Assert.Fail("Expected ArguementNullException to be thrown."); } catch (ArgumentNullException) { } }
public void TestMoveWhiteSpaceStringDestination() { var connectClient = new LiveConnectClient(new LiveConnectSession()); try { connectClient.MoveAsync("fileId.123", "\t\n "); Assert.Fail("Expected ArguementException to be thrown."); } catch (ArgumentException) { } }
public void TestMoveEmptyStringPath() { var connectClient = new LiveConnectClient(new LiveConnectSession()); try { connectClient.MoveAsync(string.Empty, "fileId.123"); Assert.Fail("Expected ArguementException to be thrown."); } catch (ArgumentException) { } }
/// <summary> /// http://msdn.microsoft.com/en-us/live/hh561740.aspx#move /// </summary> public void MoveFolderOrFile() { if (session == null) { Debug.WriteLine("You must sign in first."); } else { LiveConnectClient client = new LiveConnectClient(session); client.MoveCompleted += new EventHandler <LiveOperationCompletedEventArgs>(MoveFile_MoveCompleted); client.MoveAsync("file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!123", "folder.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!125"); } }
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); } }