/// <summary> /// Button click lisner /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Button_ClickAsync(object sender, RoutedEventArgs e) { MainWindowControler controler = new MainWindowControler(); try { RootModel model = await controler.makeQueryAsync(ingradient.Text, category.Text); if (model == null) { errorText.Text = "We don't find any recipe with your " + Environment.NewLine + "ingradients , please try again. "; return; } Window1 w = new Window1(model); w.Show(); this.Close(); } catch (NullReferenceException ex) { errorText.Text = "Please write your ingradiets"; return; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public async Task TestMethod6() { //----------Prepare components------ MainWindowControler mainControler = new WpfApp1.MainWindowControler(); String ingredients = "aazzzz"; String category = "azzzzaa"; //----------Run function------- RootModel model = await mainControler.makeQueryAsync(ingredients, category); //----------Check result------- Assert.AreEqual(true, model == null); }
public void TestMethod5() { //----------Prepare components------ MainWindowControler mainControler = new WpfApp1.MainWindowControler(); String ingredients = "eggs,ham,tomatoes"; String category = ""; //----------Run function and check result------- Assert.ThrowsExceptionAsync <NullReferenceException>(async() => { RootModel model = await mainControler.makeQueryAsync(ingredients, category); }); }
public async Task TestMethod9() { //----------Prepare components------ MainWindowControler mainControler = new WpfApp1.MainWindowControler(); String ingredients = "eggs,ham.tomatoes onions"; String category = "omelet"; //----------Run function------- RootModel model = await mainControler.makeQueryAsync(ingredients, category); //----------Check result------- Assert.AreEqual(true, model != null); Assert.AreEqual(true, model.results.Count > 0); }