public void TestNullEquals()
        {
            ProductDimension dimension = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
            value = 2L
              };

              Assert.False(comparer.Equals(dimension, null));
              Assert.False(comparer.Equals(null, dimension));
              Assert.True(comparer.Equals(null, null));
        }
        public void TestProductBiddingCategoryEquals()
        {
            ProductBiddingCategory categoryA = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
            value = 2L
              };

              ProductBiddingCategory categoryB = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
            value = 2L
              };

              ProductBiddingCategory categoryC = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L2,
            value = 2L
              };

              ProductBiddingCategory categoryD = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
            value = 5L
              };

              ProductBiddingCategory categoryE = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
              };

              ProductBiddingCategory categoryF = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
              };

              ProductBiddingCategory categoryG = new ProductBiddingCategory();
              ProductBiddingCategory categoryH = new ProductBiddingCategory();

              Assert.True(comparer.Equals(categoryA, categoryB));
              Assert.False(comparer.Equals(categoryA, categoryC));
              Assert.False(comparer.Equals(categoryA, categoryD));

              // Null value is handled gracefully.
              Assert.False(comparer.Equals(categoryA, categoryD));
              Assert.False(comparer.Equals(categoryA, categoryE));
              Assert.True(comparer.Equals(categoryE, categoryF));
              Assert.True(comparer.Equals(categoryG, categoryH));
        }
        public void TestCreateBiddingCategory()
        {
            ProductBiddingCategory categoryA = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
            value = 2L
              };

              ProductBiddingCategory categoryB = ProductDimensions.CreateBiddingCategory(
              ProductDimensionType.BIDDING_CATEGORY_L1, 2L);

              Assert.True(comparer.Equals(categoryA, categoryB));

              ProductBiddingCategory categoryC = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
              };

              ProductBiddingCategory categoryD = ProductDimensions.CreateBiddingCategory(
              ProductDimensionType.BIDDING_CATEGORY_L1);

              Assert.True(comparer.Equals(categoryC, categoryD));
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="campaignId">The campaign id to add product scope.</param>
        public void Run(AdWordsUser user, long campaignId)
        {
            // Get the CampaignCriterionService.
              CampaignCriterionService campaignCriterionService =
              (CampaignCriterionService) user.GetService(
              AdWordsService.v201601.CampaignCriterionService);

              ProductScope productScope = new ProductScope();
              // This set of dimensions is for demonstration purposes only. It would be
              // extremely unlikely that you want to include so many dimensions in your
              // product scope.
              ProductBrand nexusBrand = new ProductBrand();
              nexusBrand.value = "Nexus";

              ProductCanonicalCondition newProducts = new ProductCanonicalCondition();
              newProducts.condition = ProductCanonicalConditionCondition.NEW;

              ProductCustomAttribute customAttribute = new ProductCustomAttribute();
              customAttribute.type = ProductDimensionType.CUSTOM_ATTRIBUTE_0;
              customAttribute.value = "my attribute value";

              ProductOfferId bookOffer = new ProductOfferId();
              bookOffer.value = "book1";

              ProductType mediaProducts = new ProductType();
              mediaProducts.type = ProductDimensionType.PRODUCT_TYPE_L1;
              mediaProducts.value = "Media";

              ProductType bookProducts = new ProductType();
              bookProducts.type = ProductDimensionType.PRODUCT_TYPE_L2;
              bookProducts.value = "Books";

              // The value for the bidding category is a fixed ID for the
              // 'Luggage & Bags' category. You can retrieve IDs for categories from
              // the ConstantDataService. See the 'GetProductCategoryTaxonomy' example
              // for more details.
              ProductBiddingCategory luggageBiddingCategory = new ProductBiddingCategory();
              luggageBiddingCategory.type = ProductDimensionType.BIDDING_CATEGORY_L1;
              luggageBiddingCategory.value = -5914235892932915235;

              productScope.dimensions = new ProductDimension[] {nexusBrand, newProducts, bookOffer,
              mediaProducts, luggageBiddingCategory};

              CampaignCriterion campaignCriterion = new CampaignCriterion();
              campaignCriterion.campaignId = campaignId;
              campaignCriterion.criterion = productScope;

              // Create operation.
              CampaignCriterionOperation operation = new CampaignCriterionOperation();
              operation.operand = campaignCriterion;
              operation.@operator = Operator.ADD;

              try {
            // Make the mutate request.
            CampaignCriterionReturnValue result = campaignCriterionService.mutate(
            new CampaignCriterionOperation[] { operation });

            Console.WriteLine("Created a ProductScope criterion with ID '{0}'",
              result.value[0].criterion.id);
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to set shopping product scope.", e);
              }
        }
        public void TestProductBiddingCategoryGetHashcode()
        {
            ProductBiddingCategory categoryA = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
            value = 2L
              };

              ProductBiddingCategory categoryB = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
            value = 2L
              };

              ProductBiddingCategory categoryC = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L2,
            value = 2L
              };

              ProductBiddingCategory categoryD = new ProductBiddingCategory() {
            type = ProductDimensionType.BIDDING_CATEGORY_L1,
            value = 5L
              };

              Assert.AreEqual(comparer.GetHashCode(categoryA), comparer.GetHashCode(categoryB));
              Assert.AreNotEqual(comparer.GetHashCode(categoryA), comparer.GetHashCode(categoryC));
              Assert.AreNotEqual(comparer.GetHashCode(categoryA), comparer.GetHashCode(categoryD));
        }