private async void SearchSummonerClick(object sender, EventArgs e) { string summonerSearch = SearchInput.Text; //validate name local if (SummonerData.nameIsValid(summonerSearch)) { SummonerData sum = null; //validate name remote await RiotController.SearchSummoner(summonerSearch) .ContinueWith(task => { sum = task.Result; if (sum == null) { Device.BeginInvokeOnMainThread(() => { DisplayAlert("Summoner Not Found", "A summoner with that names does not exist", "OK"); }); } else { //push to summoner overview TEMP NavigateToSummonerOverview(sum); } }); } else { await DisplayAlert("Invalid search", "The Summoner name is invalid", "Ok"); } }
public void NameIsValidTest() { // Arrange var search1 = "22"; var search2 = "v,2as"; var search3 = "hey test"; // Act var result1 = SummonerData.nameIsValid(search1); var result2 = SummonerData.nameIsValid(search2); var result3 = SummonerData.nameIsValid(search3); // Assert Assert.IsFalse(result1); Assert.IsFalse(result2); Assert.IsTrue(result3); }