public void GetCampaignSimulation()
        {
            moq::Mock <CampaignSimulationService.CampaignSimulationServiceClient> mockGrpcClient = new moq::Mock <CampaignSimulationService.CampaignSimulationServiceClient>(moq::MockBehavior.Strict);
            GetCampaignSimulationRequest request = new GetCampaignSimulationRequest
            {
                ResourceNameAsCampaignSimulationName = gagvr::CampaignSimulationName.FromCustomerCampaignTypeModificationMethodStartDateEndDate("[CUSTOMER_ID]", "[CAMPAIGN_ID]", "[TYPE]", "[MODIFICATION_METHOD]", "[START_DATE]", "[END_DATE]"),
            };
            gagvr::CampaignSimulation expectedResponse = new gagvr::CampaignSimulation
            {
                ResourceNameAsCampaignSimulationName = gagvr::CampaignSimulationName.FromCustomerCampaignTypeModificationMethodStartDateEndDate("[CUSTOMER_ID]", "[CAMPAIGN_ID]", "[TYPE]", "[MODIFICATION_METHOD]", "[START_DATE]", "[END_DATE]"),
                CampaignId                     = -3743237468908008719L,
                Type                           = gagve::SimulationTypeEnum.Types.SimulationType.BidModifier,
                ModificationMethod             = gagve::SimulationModificationMethodEnum.Types.SimulationModificationMethod.Default,
                StartDate                      = "start_date11b9dbea",
                EndDate                        = "end_date89dae890",
                CpcBidPointList                = new gagvc::CpcBidSimulationPointList(),
                TargetCpaPointList             = new gagvc::TargetCpaSimulationPointList(),
                TargetRoasPointList            = new gagvc::TargetRoasSimulationPointList(),
                TargetImpressionSharePointList = new gagvc::TargetImpressionShareSimulationPointList(),
                BudgetPointList                = new gagvc::BudgetSimulationPointList(),
            };

            mockGrpcClient.Setup(x => x.GetCampaignSimulation(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CampaignSimulationServiceClient client   = new CampaignSimulationServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::CampaignSimulation       response = client.GetCampaignSimulation(request.ResourceName);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #2
0
        public async stt::Task GetCampaignSimulationRequestObjectAsync()
        {
            moq::Mock <CampaignSimulationService.CampaignSimulationServiceClient> mockGrpcClient = new moq::Mock <CampaignSimulationService.CampaignSimulationServiceClient>(moq::MockBehavior.Strict);
            GetCampaignSimulationRequest request = new GetCampaignSimulationRequest
            {
                ResourceNameAsCampaignSimulationName = gagvr::CampaignSimulationName.FromCustomerCampaignTypeModificationMethodStartDateEndDate("[CUSTOMER_ID]", "[CAMPAIGN_ID]", "[TYPE]", "[MODIFICATION_METHOD]", "[START_DATE]", "[END_DATE]"),
            };
            gagvr::CampaignSimulation expectedResponse = new gagvr::CampaignSimulation
            {
                ResourceNameAsCampaignSimulationName = gagvr::CampaignSimulationName.FromCustomerCampaignTypeModificationMethodStartDateEndDate("[CUSTOMER_ID]", "[CAMPAIGN_ID]", "[TYPE]", "[MODIFICATION_METHOD]", "[START_DATE]", "[END_DATE]"),
                CampaignId                     = -3743237468908008719L,
                Type                           = gagve::SimulationTypeEnum.Types.SimulationType.BidModifier,
                ModificationMethod             = gagve::SimulationModificationMethodEnum.Types.SimulationModificationMethod.Default,
                StartDate                      = "start_date11b9dbea",
                EndDate                        = "end_date89dae890",
                CpcBidPointList                = new gagvc::CpcBidSimulationPointList(),
                TargetCpaPointList             = new gagvc::TargetCpaSimulationPointList(),
                TargetRoasPointList            = new gagvc::TargetRoasSimulationPointList(),
                TargetImpressionSharePointList = new gagvc::TargetImpressionShareSimulationPointList(),
                BudgetPointList                = new gagvc::BudgetSimulationPointList(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }