public void GetProductSearchPage()
        {
            Assert.IsNotNull(TestData.Category2CS);
            //
            Int32Collection l = new Int32Collection();
            for(int i = 0; i < TestData.Category2CS.Count; i++ )
            {
            CategoryType c = TestData.Category2CS[i];
            if( c.ProductSearchPageAvailableSpecified && c.ProductSearchPageAvailable
            && c.CharacteristicsSets != null && c.CharacteristicsSets.Count > 0
            )
            {
            l.Add(c.CharacteristicsSets[0].AttributeSetID);
            break;
            }
            }
            //
            GetProductSearchPageCall api = new GetProductSearchPageCall(this.apiContext);
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
               DetailLevelCodeType.ReturnAll
            };
            api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            api.AttributeSetIDList = l;
            // Make API call.
            ProductSearchPageTypeCollection searchPages = api.GetProductSearchPage();
            Assert.IsNotNull(searchPages);
            Assert.IsTrue(searchPages.Count > 0);
            TestData.ProductSearchPages = searchPages;
        }
 public void GetProductSearchPageFull()
 {
     Assert.IsNotNull(TestData.Category2CS2);
     //here comes out hard code.
     //the category should be children books category.
     Assert.IsTrue((string.Compare(TestData.Category2CS2.CategoryID,childrenBookCategory,true)==0));
     Int32Collection attributeSets = new Int32Collection();
     CategoryType category = TestData.Category2CS2;
     Assert.Greater(category.CharacteristicsSets.Count,0);
     for(int i=0; i< category.CharacteristicsSets.Count;i++)
     {
         attributeSets.Add(category.CharacteristicsSets[i].AttributeSetID);
     }
     Assert.Greater(attributeSets.Count,0);
     GetProductSearchPageCall api = new GetProductSearchPageCall(this.apiContext);
     DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
     DetailLevelCodeType.ReturnAll
     };
     api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
     api.AttributeSetIDList = attributeSets;
     api.Execute();
     //check whether the call is success.
     Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning,"the call is failure!");
     Assert.IsNotNull(api.ApiResponse.ProductSearchPage);
     Assert.Greater(api.ApiResponse.ProductSearchPage.Count,0);
     //the children category's SearchCharacteristicsSet property has value.
     Assert.IsNotNull(api.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet);
     Assert.Greater(api.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics.Count,0);
     //cache the children's mapping data.
     TestData.ProductSearchPages2 = api.ApiResponse.ProductSearchPage;
 }
Beispiel #3
0
        public void AddItemFull3()
        {
            bool isSucess,isProductSearchPageAvailable;
            bool existing=false,isbnExisting=false;
            string message;
            Int32Collection attributes=new Int32Collection();
            CategoryTypeCollection categories=null;
            CharacteristicsSetTypeCollection characteristics=null;

            ItemType item= ItemHelper.BuildItem();
            //check whether the category is catalog enabled.
            isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,PSPACATEGORYID.ToString(),CategoryEnableCodeType.ProductSearchPageAvailable,out isProductSearchPageAvailable,out message);
            Assert.IsTrue(isSucess,message);
            Assert.IsTrue(isProductSearchPageAvailable,message);
            isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,PSPACATEGORYID.ToString(),CategoryEnableCodeType.CatalogEnabled,out isProductSearchPageAvailable,out message);
            Assert.IsTrue(isSucess,message);
            Assert.IsTrue(isProductSearchPageAvailable,message);
            //modify item information approporiately.
            item.PrimaryCategory.CategoryID=PSPACATEGORYID.ToString();
            item.Description = "check whether the item can be added by GetProductSearchPage method way,This is a test item created by eBay SDK SanityTest.";

            //get characters information using GetCategory2CSCall
            GetCategory2CSCall csCall=new GetCategory2CSCall(this.apiContext);

            DetailLevelCodeTypeCollection levels=new DetailLevelCodeTypeCollection();
            DetailLevelCodeType level=new DetailLevelCodeType();
            level=DetailLevelCodeType.ReturnAll;
            levels.Add(level);
            csCall.DetailLevelList=levels;
            csCall.CategoryID=PSPACATEGORYID.ToString();
            csCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(csCall.AbstractResponse.Ack==AckCodeType.Success || csCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.IsNotNull(csCall.ApiResponse.MappedCategoryArray);
            Assert.Greater(csCall.ApiResponse.MappedCategoryArray.Count,0);
            categories=csCall.ApiResponse.MappedCategoryArray;

            foreach(CategoryType category in categories)
            {
                if(string.Compare(category.CategoryID,PSPACATEGORYID)==0)
                {
                    characteristics=category.CharacteristicsSets;
                    existing= true;
                    break;
                }
            }

            //confirm that the category was in the mapping category.
            Assert.IsTrue(existing,PSPACATEGORYID+" do not exist in the mapping category");
            Assert.IsNotNull(characteristics);
            Assert.Greater(characteristics.Count,0);

            foreach(CharacteristicsSetType characteristic in characteristics)
            {
                attributes.Add(characteristic.AttributeSetID);
            }

            //confirm that there is real attributeset in the mapping category.
            Assert.AreEqual(attributes.Count,1);//there is only one AttributeSetID in the category 279.

            GetProductSearchPageCall searchPageCall=new GetProductSearchPageCall(this.apiContext);
            searchPageCall.AttributeSetIDList=attributes;
            DetailLevelCodeTypeCollection levels2=new DetailLevelCodeTypeCollection();
            DetailLevelCodeType level2=new DetailLevelCodeType();
            level2=DetailLevelCodeType.ReturnAll;
            levels2.Add(level2);
            searchPageCall.DetailLevelList=levels2;
            searchPageCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(searchPageCall.ApiResponse.Ack==AckCodeType.Success || searchPageCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.AreEqual(searchPageCall.ApiResponse.ProductSearchPage.Count,1);//for the input attributeset id is only one.
            Assert.IsNotNull(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet);//for the input attributeset id is only one.
            Assert.IsNotNull(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics);
            Assert.Greater(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics.Count,0);

            //check the isbn-13 attribute id exists and its value has not been changed.
            CharacteristicTypeCollection chs = searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics;
            foreach(CharacteristicType charactersic in chs)
            {
                //check whether the isbn attribute can be used
                if(charactersic.AttributeID==ISBN13ATTRIBUTEID && (string.Compare(charactersic.Label.Name,"ISBN-13",true)==0))
                {
                    isbnExisting=true;
                    break;
                }
            }

            Assert.IsTrue(isbnExisting,"the isbn attribute id is not existing or has been changed!");
            //using GetProductSearchResults call to find products.
            ProductSearchType productSearch=new ProductSearchType();
            productSearch.AttributeSetID=attributes[0];
            SearchAttributesTypeCollection searchAttributes=new SearchAttributesTypeCollection();
            SearchAttributesType searchAttribute=new SearchAttributesType();
            searchAttribute.AttributeID=ISBN13ATTRIBUTEID;
            ValTypeCollection vals=new ValTypeCollection();
            ValType val=new ValType();
            val.ValueLiteral=ISBN;
            vals.Add(val);
            searchAttribute.ValueList=vals;
            searchAttributes.Add(searchAttribute);
            productSearch.SearchAttributes=searchAttributes;
            GetProductSearchResultsCall searchResultsCall=new GetProductSearchResultsCall(this.apiContext);
            searchResultsCall.ProductSearchList=new ProductSearchTypeCollection(new ProductSearchType[]{productSearch});
            searchResultsCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(searchResultsCall.ApiResponse.Ack==AckCodeType.Success || searchResultsCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult.Count,0);
            Assert.AreEqual(int.Parse(searchResultsCall.ApiResponse.ProductSearchResult[0].NumProducts),1);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet.Count,0);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies.Count,0);
            Assert.IsFalse(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].hasMoreChildren);
            Assert.IsNotNull(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID);

            string productID=searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID;
            ProductListingDetailsType plist=new ProductListingDetailsType();
            plist.ProductID=productID;
            plist.IncludePrefilledItemInformation=true;
            plist.IncludeStockPhotoURL=true;
            item.ProductListingDetails=plist;

            FeeTypeCollection fees;

            VerifyAddItemCall vi = new VerifyAddItemCall(apiContext);
            fees = vi.VerifyAddItem(item);
            Assert.IsNotNull(fees);

            AddItemCall addItemCall = new AddItemCall(apiContext);;
            fees = addItemCall.AddItem(item);
            //check whether the call is success.
            Assert.IsTrue(addItemCall.AbstractResponse.Ack==AckCodeType.Success || addItemCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.IsTrue(item.ItemID!=string.Empty);
            Assert.IsNotNull(fees);

            //caution check
            ItemType itemOut;
            isSucess=ItemHelper.GetItem(item,this.apiContext,out message, out itemOut);
            Assert.IsTrue(isSucess,message);
            Assert.IsNotNull(itemOut,"Item is null");
            Assert.Greater(itemOut.AttributeSetArray.Count,0);
            Assert.Greater(itemOut.AttributeSetArray[0].Attribute.Count,0);
            Assert.Greater(itemOut.AttributeSetArray[0].Attribute[0].Value.Count,0);
        }
        private void BtnGetProductSearchPage_Click(object sender, System.EventArgs e)
        {
            try
            {
                LstProductData.Items.Clear();

                GetProductSearchPageCall apicall = new GetProductSearchPageCall(Context);
                apicall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
                if (TxtSearchPageVersion.Text != String.Empty)
                    apicall.AttributeVersion = TxtSearchPageVersion.Text;

                if (TxtSearchPageSets.Text != String.Empty)
                {
                    apicall.AttributeSetIDList = new Int32Collection();

                    string[] atts = TxtSearchPageSets.Text.Split(',');
                    foreach (string att in atts)
                    {
                        apicall.AttributeSetIDList.Add(Convert.ToInt32(att));
                    }
                }

                ProductSearchPageTypeCollection spages = apicall.GetProductSearchPage();

                foreach (ProductSearchPageType page in spages)
                {

                    foreach (CharacteristicType val in page.SearchCharacteristicsSet.Characteristics)
                    {
                        string[] listparams = new string[3];

                        listparams[0] = val.AttributeID.ToString();
                        listparams[1] = val.DisplaySequence;
                        listparams[2] = val.Label.Name;

                        ListViewItem vi = new ListViewItem(listparams);
                        LstProductData.Items.Add(vi);
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }