コード例 #1
0
        /// <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());
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
            });
        }
コード例 #4
0
        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);
        }