Пример #1
0
        public async stt::Task MutateCampaignBudgetsAsync()
        {
            moq::Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new moq::Mock <CampaignBudgetService.CampaignBudgetServiceClient>(moq::MockBehavior.Strict);
            MutateCampaignBudgetsRequest request = new MutateCampaignBudgetsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CampaignBudgetOperation(),
                },
            };
            MutateCampaignBudgetsResponse expectedResponse = new MutateCampaignBudgetsResponse
            {
                Results =
                {
                    new MutateCampaignBudgetResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCampaignBudgetsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateCampaignBudgetsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CampaignBudgetServiceClient   client = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignBudgetsResponse responseCallSettings = await client.MutateCampaignBudgetsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            Assert.AreEqual(expectedResponse, responseCallSettings);
            MutateCampaignBudgetsResponse responseCancellationToken = await client.MutateCampaignBudgetsAsync(request.CustomerId, request.Operations, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Пример #2
0
        public void MutateCampaignBudgets()
        {
            moq::Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new moq::Mock <CampaignBudgetService.CampaignBudgetServiceClient>(moq::MockBehavior.Strict);
            MutateCampaignBudgetsRequest request = new MutateCampaignBudgetsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CampaignBudgetOperation(),
                },
            };
            MutateCampaignBudgetsResponse expectedResponse = new MutateCampaignBudgetsResponse
            {
                Results =
                {
                    new MutateCampaignBudgetResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCampaignBudgets(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CampaignBudgetServiceClient   client   = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignBudgetsResponse response = client.MutateCampaignBudgets(request.CustomerId, request.Operations);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #3
0
        public void GetCampaignBudgetRequestObject()
        {
            moq::Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new moq::Mock <CampaignBudgetService.CampaignBudgetServiceClient>(moq::MockBehavior.Strict);
            GetCampaignBudgetRequest request = new GetCampaignBudgetRequest
            {
                ResourceNameAsCampaignBudgetName = gagvr::CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER]", "[CAMPAIGN_BUDGET]"),
            };
            gagvr::CampaignBudget expectedResponse = new gagvr::CampaignBudget
            {
                ResourceNameAsCampaignBudgetName = gagvr::CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER]", "[CAMPAIGN_BUDGET]"),
                Id = -6774108720365892680L,
                CampaignBudgetName            = gagvr::CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER]", "[CAMPAIGN_BUDGET]"),
                AmountMicros                  = -5708430407335026218L,
                Status                        = gagve::BudgetStatusEnum.Types.BudgetStatus.Enabled,
                DeliveryMethod                = gagve::BudgetDeliveryMethodEnum.Types.BudgetDeliveryMethod.Standard,
                ExplicitlyShared              = true,
                ReferenceCount                = -8440758895662409664L,
                TotalAmountMicros             = -8735537612243809071L,
                HasRecommendedBudget          = false,
                RecommendedBudgetAmountMicros = -5174015606152417050L,
                Period                        = gagve::BudgetPeriodEnum.Types.BudgetPeriod.Unknown,
                RecommendedBudgetEstimatedChangeWeeklyClicks       = 5003538975719544582L,
                RecommendedBudgetEstimatedChangeWeeklyCostMicros   = 6886876539534848907L,
                RecommendedBudgetEstimatedChangeWeeklyInteractions = -4068174795511900246L,
                RecommendedBudgetEstimatedChangeWeeklyViews        = -4598204636615893095L,
                Type = gagve::BudgetTypeEnum.Types.BudgetType.Unspecified,
            };

            mockGrpcClient.Setup(x => x.GetCampaignBudget(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CampaignBudgetServiceClient client   = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::CampaignBudget       response = client.GetCampaignBudget(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void MutateCampaignBudgetsRequestObject()
        {
            moq::Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new moq::Mock <CampaignBudgetService.CampaignBudgetServiceClient>(moq::MockBehavior.Strict);
            MutateCampaignBudgetsRequest request = new MutateCampaignBudgetsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new CampaignBudgetOperation(),
                },
                PartialFailure      = false,
                ValidateOnly        = true,
                ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly,
            };
            MutateCampaignBudgetsResponse expectedResponse = new MutateCampaignBudgetsResponse
            {
                Results =
                {
                    new MutateCampaignBudgetResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateCampaignBudgets(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CampaignBudgetServiceClient   client   = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignBudgetsResponse response = client.MutateCampaignBudgets(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task MutateCampaignBudgetsAsync3()
        {
            Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new Mock <CampaignBudgetService.CampaignBudgetServiceClient>(MockBehavior.Strict);
            MutateCampaignBudgetsRequest request = new MutateCampaignBudgetsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateCampaignBudgetsResponse expectedResponse = new MutateCampaignBudgetsResponse();

            mockGrpcClient.Setup(x => x.MutateCampaignBudgetsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignBudgetsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CampaignBudgetServiceClient   client   = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignBudgetsResponse response = await client.MutateCampaignBudgetsAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void MutateCampaignBudgets3()
        {
            Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new Mock <CampaignBudgetService.CampaignBudgetServiceClient>(MockBehavior.Strict);
            MutateCampaignBudgetsRequest request = new MutateCampaignBudgetsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateCampaignBudgetsResponse expectedResponse = new MutateCampaignBudgetsResponse();

            mockGrpcClient.Setup(x => x.MutateCampaignBudgets(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            CampaignBudgetServiceClient   client   = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null);
            MutateCampaignBudgetsResponse response = client.MutateCampaignBudgets(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetCampaignBudget2()
        {
            Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new Mock <CampaignBudgetService.CampaignBudgetServiceClient>(MockBehavior.Strict);
            GetCampaignBudgetRequest request = new GetCampaignBudgetRequest
            {
                ResourceName = new CampaignBudgetName("[CUSTOMER]", "[CAMPAIGN_BUDGET]").ToString(),
            };
            CampaignBudget expectedResponse = new CampaignBudget
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetCampaignBudget(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            CampaignBudgetServiceClient client = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null);
            CampaignBudget response            = client.GetCampaignBudget(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task GetCampaignBudgetAsync2()
        {
            Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new Mock <CampaignBudgetService.CampaignBudgetServiceClient>(MockBehavior.Strict);
            GetCampaignBudgetRequest request = new GetCampaignBudgetRequest
            {
                ResourceName = new CampaignBudgetName("[CUSTOMER]", "[CAMPAIGN_BUDGET]").ToString(),
            };
            CampaignBudget expectedResponse = new CampaignBudget
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetCampaignBudgetAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <CampaignBudget>(Task.FromResult(expectedResponse), null, null, null, null));
            CampaignBudgetServiceClient client = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null);
            CampaignBudget response            = await client.GetCampaignBudgetAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task GetCampaignBudgetResourceNamesAsync()
        {
            moq::Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new moq::Mock <CampaignBudgetService.CampaignBudgetServiceClient>(moq::MockBehavior.Strict);
            GetCampaignBudgetRequest request = new GetCampaignBudgetRequest
            {
                ResourceNameAsCampaignBudgetName = gagvr::CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER_ID]", "[CAMPAIGN_BUDGET_ID]"),
            };
            gagvr::CampaignBudget expectedResponse = new gagvr::CampaignBudget
            {
                ResourceNameAsCampaignBudgetName = gagvr::CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER_ID]", "[CAMPAIGN_BUDGET_ID]"),
                Status                        = gagve::BudgetStatusEnum.Types.BudgetStatus.Enabled,
                DeliveryMethod                = gagve::BudgetDeliveryMethodEnum.Types.BudgetDeliveryMethod.Standard,
                Period                        = gagve::BudgetPeriodEnum.Types.BudgetPeriod.Unspecified,
                Type                          = gagve::BudgetTypeEnum.Types.BudgetType.Unspecified,
                Id                            = -6774108720365892680L,
                CampaignBudgetName            = gagvr::CampaignBudgetName.FromCustomerCampaignBudget("[CUSTOMER_ID]", "[CAMPAIGN_BUDGET_ID]"),
                AmountMicros                  = -5708430407335026218L,
                TotalAmountMicros             = -8735537612243809071L,
                ExplicitlyShared              = true,
                ReferenceCount                = -8440758895662409664L,
                HasRecommendedBudget          = false,
                RecommendedBudgetAmountMicros = -5174015606152417050L,
                RecommendedBudgetEstimatedChangeWeeklyClicks       = 5003538975719544582L,
                RecommendedBudgetEstimatedChangeWeeklyCostMicros   = 6886876539534848907L,
                RecommendedBudgetEstimatedChangeWeeklyInteractions = -4068174795511900246L,
                RecommendedBudgetEstimatedChangeWeeklyViews        = -4598204636615893095L,
            };

            mockGrpcClient.Setup(x => x.GetCampaignBudgetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::CampaignBudget>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CampaignBudgetServiceClient client = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::CampaignBudget       responseCallSettings = await client.GetCampaignBudgetAsync(request.ResourceNameAsCampaignBudgetName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            gagvr::CampaignBudget responseCancellationToken = await client.GetCampaignBudgetAsync(request.ResourceNameAsCampaignBudgetName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task MutateCampaignBudgetsAsync()
        {
            Mock <CampaignBudgetService.CampaignBudgetServiceClient> mockGrpcClient = new Mock <CampaignBudgetService.CampaignBudgetServiceClient>(MockBehavior.Strict);
            MutateCampaignBudgetsRequest expectedRequest = new MutateCampaignBudgetsRequest
            {
                CustomerId     = "customerId-1772061412",
                Operations     = { },
                PartialFailure = true,
                ValidateOnly   = false,
            };
            MutateCampaignBudgetsResponse expectedResponse = new MutateCampaignBudgetsResponse();

            mockGrpcClient.Setup(x => x.MutateCampaignBudgetsAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateCampaignBudgetsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            CampaignBudgetServiceClient client = new CampaignBudgetServiceClientImpl(mockGrpcClient.Object, null);
            string customerId = "customerId-1772061412";
            IEnumerable <CampaignBudgetOperation> operations = new List <CampaignBudgetOperation>();
            bool partialFailure = true;
            bool validateOnly   = false;
            MutateCampaignBudgetsResponse response = await client.MutateCampaignBudgetsAsync(customerId, operations, partialFailure, validateOnly);

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