public async stt::Task GetAdGroupRequestObjectAsync() { moq::Mock <AdGroupService.AdGroupServiceClient> mockGrpcClient = new moq::Mock <AdGroupService.AdGroupServiceClient>(moq::MockBehavior.Strict); GetAdGroupRequest request = new GetAdGroupRequest { ResourceNameAsAdGroupName = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER_ID]", "[AD_GROUP_ID]"), }; gagvr::AdGroup expectedResponse = new gagvr::AdGroup { ResourceNameAsAdGroupName = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER_ID]", "[AD_GROUP_ID]"), Status = gagve::AdGroupStatusEnum.Types.AdGroupStatus.Removed, UrlCustomParameters = { new gagvc::CustomParameter(), }, Type = gagve::AdGroupTypeEnum.Types.AdGroupType.VideoTrueViewInDisplay, ExplorerAutoOptimizerSetting = new gagvc::ExplorerAutoOptimizerSetting(), AdRotationMode = gagve::AdGroupAdRotationModeEnum.Types.AdGroupAdRotationMode.Unspecified, DisplayCustomBidDimension = gagve::TargetingDimensionEnum.Types.TargetingDimension.AgeRange, TargetingSetting = new gagvc::TargetingSetting(), EffectiveTargetCpaSource = gagve::BiddingSourceEnum.Types.BiddingSource.Unknown, EffectiveTargetRoasSource = gagve::BiddingSourceEnum.Types.BiddingSource.AdGroupCriterion, Id = -6774108720365892680L, AdGroupName = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER_ID]", "[AD_GROUP_ID]"), BaseAdGroupAsAdGroupName = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER_ID]", "[AD_GROUP_ID]"), TrackingUrlTemplate = "tracking_url_template157f152a", CampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"), CpcBidMicros = 7321761304249472746L, CpmBidMicros = -6938481569984464040L, TargetCpaMicros = 5263516020894046876L, CpvBidMicros = 3393527949878021854L, TargetCpmMicros = 2683842186664132327L, TargetRoas = 1.0830159587289216E+18, PercentCpcBidMicros = 3342096754779167220L, FinalUrlSuffix = "final_url_suffix046ed37a", EffectiveTargetCpaMicros = 9173558632194584770L, EffectiveTargetRoas = -5.789428044530098E+17, LabelsAsAdGroupLabelNames = { gagvr::AdGroupLabelName.FromCustomerAdGroupLabel("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[LABEL_ID]"), }, ExcludedParentAssetFieldTypes = { gagve::AssetFieldTypeEnum.Types.AssetFieldType.HotelCallout, }, }; mockGrpcClient.Setup(x => x.GetAdGroupAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::AdGroup>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AdGroupServiceClient client = new AdGroupServiceClientImpl(mockGrpcClient.Object, null); gagvr::AdGroup responseCallSettings = await client.GetAdGroupAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::AdGroup responseCancellationToken = await client.GetAdGroupAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetAdGroupAsync2() { Mock <AdGroupService.AdGroupServiceClient> mockGrpcClient = new Mock <AdGroupService.AdGroupServiceClient>(MockBehavior.Strict); GetAdGroupRequest request = new GetAdGroupRequest { ResourceName = new AdGroupName("[CUSTOMER]", "[AD_GROUP]").ToString(), }; AdGroup expectedResponse = new AdGroup { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetAdGroupAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <AdGroup>(Task.FromResult(expectedResponse), null, null, null, null)); AdGroupServiceClient client = new AdGroupServiceClientImpl(mockGrpcClient.Object, null); AdGroup response = await client.GetAdGroupAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }