Пример #1
0
        public async stt::Task GetCampaignBudgetRequestObjectAsync()
        {
            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.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, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            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();
        }