/// <summary> /// Mehod for the Delete button clicked event. /// </summary> /// <param name="sender">Sender Object</param> /// <param name="e">EventArgs e</param> private async void delButton_Clicked(object sender, EventArgs e) { if (id != null) { ApiSV sv = new ApiSV(); sv.url = sv.UrlBuilder("/" + id); var answer = await DisplayAlert("Wait!", "Are you sure you want to delete this transaction?", "YES", "NO"); if (answer) { try { load.IsRunning = true; await sv.Delete <TransactionModel>(); load.IsRunning = false; await DisplayAlert("Success!", "Transaction was deleted!", "OK"); await Navigation.PopToRootAsync(); } catch { await DisplayAlert("Error", "Something went wrong with the API Call, Try Again!", "OK"); load.IsRunning = false; } } else { return; } } }
public async System.Threading.Tasks.Task TestDeleteAsync() { //Arrange ApiSV sv = new ApiSV(); string id = transactionDatum.Last()._id; sv.url = sv.UrlBuilder("/" + id); //Act try { await sv.Delete <TransactionModel>(); } catch (Exception ex) { Debug.WriteLine(Convert.ToString(ex.Message)); } //Assert Assert.IsTrue(transactionDatum.Count != 0); //Means that there is data from the Api Get call. Assert.IsTrue(sv.Delete <TransactionModel>().IsCompleted); //Means that Post method was completed //Assert.IsTrue(transactionDatum[0].Category.Equals("Testing put")); }