Exemple #1
0
        private void BtnGetSuggestedCategories_Click(object sender, System.EventArgs e)
        {
            try
            {
                LstCategories.Items.Clear();

                GetSuggestedCategoriesCall apicall = new GetSuggestedCategoriesCall(Context);

                SuggestedCategoryTypeCollection cats = apicall.GetSuggestedCategories(TxtQuery.Text);

                if (cats != null)
                {
                    foreach (SuggestedCategoryType category in cats)
                    {
                        string[] listparams = new string[3];
                        listparams[0] = category.Category.CategoryID;
                        listparams[1] = String.Join(" : ", category.Category.CategoryParentName.ToArray()) + " : " + category.Category.CategoryName;
                        listparams[2] = category.PercentItemFound.ToString();

                        ListViewItem vi = new ListViewItem(listparams);
                        this.LstCategories.Items.Add(vi);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void GetSuggestedCategories()
        {
            GetSuggestedCategoriesCall api = new GetSuggestedCategoriesCall(this.apiContext);

            api.Query = "DVD";
            SuggestedCategoryTypeCollection cats = api.GetSuggestedCategories(api.Query);

            //check whether the call is success.
            Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning, "the call is failure!");
            Assert.IsNotNull(cats);
            Assert.IsTrue(cats.Count > 0);
            //check the category number is right
            Assert.AreEqual(cats.Count, api.ApiResponse.CategoryCount);
        }