Exemplo n.º 1
0
 /// <summary>
 /// Delete the user with the specified id
 /// </summary>
 /// <param name="id">Id of the user object to delete</param>
 /// <param name="options">Request specific api options. These will override the global settings for the app for this request.</param>
 /// <returns>Void</returns>
 public static async Task DeleteUserAsync(string id, bool deleteConnections = false, ApiOptions options = null)
 {
     var request = new DeleteUserRequest() { UserId = id, DeleteConnections = deleteConnections };
     ApiOptions.Apply(request, options);
     var response = await request.ExecuteAsync();
     if (response.Status.IsSuccessful == false)
         throw response.Status.ToFault();
 }
        public async Task DeleteUserAsyncTest()
        {
            // Create new user
            var newUser = await UserHelper.CreateNewUserAsync();

            // Authenticate the user
            await AppContext.LoginAsync(new UsernamePasswordCredentials(newUser.Username, newUser.Password));

            // Delete the user
            var request = new DeleteUserRequest() { UserId = newUser.Id };

            var response = await request.ExecuteAsync();
            ApiHelper.EnsureValidResponse(response);

            // Try to get the user
            var getResponse = await (new GetUserRequest() { UserId = newUser.Id }).ExecuteAsync();
            ApiHelper.EnsureValidResponse(getResponse, false);
            Assert.IsFalse(getResponse.Status.IsSuccessful, "Get for an non-existant user did not fail.");
            Console.WriteLine("Get user error message: {0}", getResponse.Status.Message);
        }