예제 #1
0
        public void GetRecommendationResourceNames()
        {
            moq::Mock <RecommendationService.RecommendationServiceClient> mockGrpcClient = new moq::Mock <RecommendationService.RecommendationServiceClient>(moq::MockBehavior.Strict);
            GetRecommendationRequest request = new GetRecommendationRequest
            {
                ResourceNameAsRecommendationName = gagvr::RecommendationName.FromCustomerRecommendation("[CUSTOMER_ID]", "[RECOMMENDATION_ID]"),
            };
            gagvr::Recommendation expectedResponse = new gagvr::Recommendation
            {
                ResourceNameAsRecommendationName = gagvr::RecommendationName.FromCustomerRecommendation("[CUSTOMER_ID]", "[RECOMMENDATION_ID]"),
                Type   = gagve::RecommendationTypeEnum.Types.RecommendationType.MaximizeClicksOptIn,
                Impact = new gagvr::Recommendation.Types.RecommendationImpact(),
                CampaignBudgetRecommendation            = new gagvr::Recommendation.Types.CampaignBudgetRecommendation(),
                KeywordRecommendation                   = new gagvr::Recommendation.Types.KeywordRecommendation(),
                TextAdRecommendation                    = new gagvr::Recommendation.Types.TextAdRecommendation(),
                TargetCpaOptInRecommendation            = new gagvr::Recommendation.Types.TargetCpaOptInRecommendation(),
                MaximizeConversionsOptInRecommendation  = new gagvr::Recommendation.Types.MaximizeConversionsOptInRecommendation(),
                EnhancedCpcOptInRecommendation          = new gagvr::Recommendation.Types.EnhancedCpcOptInRecommendation(),
                SearchPartnersOptInRecommendation       = new gagvr::Recommendation.Types.SearchPartnersOptInRecommendation(),
                MaximizeClicksOptInRecommendation       = new gagvr::Recommendation.Types.MaximizeClicksOptInRecommendation(),
                OptimizeAdRotationRecommendation        = new gagvr::Recommendation.Types.OptimizeAdRotationRecommendation(),
                CalloutExtensionRecommendation          = new gagvr::Recommendation.Types.CalloutExtensionRecommendation(),
                SitelinkExtensionRecommendation         = new gagvr::Recommendation.Types.SitelinkExtensionRecommendation(),
                CallExtensionRecommendation             = new gagvr::Recommendation.Types.CallExtensionRecommendation(),
                KeywordMatchTypeRecommendation          = new gagvr::Recommendation.Types.KeywordMatchTypeRecommendation(),
                MoveUnusedBudgetRecommendation          = new gagvr::Recommendation.Types.MoveUnusedBudgetRecommendation(),
                ForecastingCampaignBudgetRecommendation = new gagvr::Recommendation.Types.CampaignBudgetRecommendation(),
                TargetRoasOptInRecommendation           = new gagvr::Recommendation.Types.TargetRoasOptInRecommendation(),
                CampaignBudgetAsCampaignBudgetName      = gagvr::CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER_ID]", "[CAMPAIGN_BUDGET_ID]"),
                CampaignAsCampaignName                  = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"),
                AdGroupAsAdGroupName                    = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER_ID]", "[AD_GROUP_ID]"),
                Dismissed = true,
            };

            mockGrpcClient.Setup(x => x.GetRecommendation(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            RecommendationServiceClient client   = new RecommendationServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::Recommendation       response = client.GetRecommendation(request.ResourceNameAsRecommendationName);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetRecommendation()
        {
            Mock <RecommendationService.RecommendationServiceClient> mockGrpcClient = new Mock <RecommendationService.RecommendationServiceClient>(MockBehavior.Strict);
            GetRecommendationRequest expectedRequest = new GetRecommendationRequest
            {
                ResourceName = new RecommendationName("[CUSTOMER]", "[RECOMMENDATION]").ToString(),
            };
            Recommendation expectedResponse = new Recommendation
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetRecommendation(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            RecommendationServiceClient client   = new RecommendationServiceClientImpl(mockGrpcClient.Object, null);
            string         formattedResourceName = new RecommendationName("[CUSTOMER]", "[RECOMMENDATION]").ToString();
            Recommendation response = client.GetRecommendation(formattedResourceName);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }