public async stt::Task GetCampaignBidModifierResourceNamesAsync() { moq::Mock <CampaignBidModifierService.CampaignBidModifierServiceClient> mockGrpcClient = new moq::Mock <CampaignBidModifierService.CampaignBidModifierServiceClient>(moq::MockBehavior.Strict); GetCampaignBidModifierRequest request = new GetCampaignBidModifierRequest { ResourceNameAsCampaignBidModifierName = gagvr::CampaignBidModifierName.FromCustomerCampaignBidModifier("[CUSTOMER]", "[CAMPAIGN_BID_MODIFIER]"), }; gagvr::CampaignBidModifier expectedResponse = new gagvr::CampaignBidModifier { ResourceNameAsCampaignBidModifierName = gagvr::CampaignBidModifierName.FromCustomerCampaignBidModifier("[CUSTOMER]", "[CAMPAIGN_BID_MODIFIER]"), CampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), CriterionId = 8584655242409302840L, BidModifier = 1.6595195068951933E+17, InteractionType = new gagvc::InteractionTypeInfo(), }; mockGrpcClient.Setup(x => x.GetCampaignBidModifierAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::CampaignBidModifier>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CampaignBidModifierServiceClient client = new CampaignBidModifierServiceClientImpl(mockGrpcClient.Object, null); gagvr::CampaignBidModifier responseCallSettings = await client.GetCampaignBidModifierAsync(request.ResourceNameAsCampaignBidModifierName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::CampaignBidModifier responseCancellationToken = await client.GetCampaignBidModifierAsync(request.ResourceNameAsCampaignBidModifierName, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetCampaignBidModifierAsync2() { Mock <CampaignBidModifierService.CampaignBidModifierServiceClient> mockGrpcClient = new Mock <CampaignBidModifierService.CampaignBidModifierServiceClient>(MockBehavior.Strict); GetCampaignBidModifierRequest request = new GetCampaignBidModifierRequest { ResourceName = new CampaignBidModifierName("[CUSTOMER]", "[CAMPAIGN_BID_MODIFIER]").ToString(), }; CampaignBidModifier expectedResponse = new CampaignBidModifier { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetCampaignBidModifierAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <CampaignBidModifier>(Task.FromResult(expectedResponse), null, null, null, null)); CampaignBidModifierServiceClient client = new CampaignBidModifierServiceClientImpl(mockGrpcClient.Object, null); CampaignBidModifier response = await client.GetCampaignBidModifierAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }