public async Task IntegratedTest()
        {
            int nutid = await NutritionalValue.getProductId("Cheddar cheese");

            Nutrition nutrition = NutritionalValue.getNutritionalValue(nutid).Result;

            Assert.IsNotNull(nutrition);
        }
Пример #2
0
        private async void ExecuteGetNutrientValueAsync()
        {
            IceCreamModel.SumCal     = null;
            IceCreamModel.SumProtein = null;
            IceCreamModel.SumFat     = null;
            IsGetNutrienCommandBusy  = true;
            if (string.IsNullOrWhiteSpace(IceCreamModel.Name))
            {
                SnackbarMessageQueue.Enqueue("Please, Enter an ice cream name and then click.");
            }
            else
            {
                try
                {
                    int nutrienId = await NutritionalValue.getProductId(IceCreamModel.Name);

                    if (nutrienId == -1)
                    {
                        SnackbarMessageQueue.Enqueue("Oops... your Ice Cream name not match any nutritional value. please try change the name");
                    }
                    else
                    {
                        Nutrition nutrition = await NutritionalValue.getNutritionalValue(nutrienId);

                        IceCreamModel.SumCal     = nutrition.Energy;
                        IceCreamModel.SumProtein = nutrition.Protein;
                        IceCreamModel.SumFat     = nutrition.Fat;
                    }
                }
                catch (Exception)
                {
                    SnackbarMessageQueue.Enqueue("Oops... Can Not Get Nutrient Value Now.", "Ok", () => { }, false);
                }
            }

            IsGetNutrienCommandBusy = false;
            CommandManager.InvalidateRequerySuggested();
        }
        public async Task TestByGeneralSearch()
        {
            int nutid = await NutritionalValue.getProductId("Cheddar cheese");

            Assert.AreNotEqual(-1, nutid);
        }