public void GetFeedItemTarget() { moq::Mock <FeedItemTargetService.FeedItemTargetServiceClient> mockGrpcClient = new moq::Mock <FeedItemTargetService.FeedItemTargetServiceClient>(moq::MockBehavior.Strict); GetFeedItemTargetRequest request = new GetFeedItemTargetRequest { ResourceNameAsFeedItemTargetName = gagvr::FeedItemTargetName.FromCustomerFeedItemTarget("[CUSTOMER]", "[FEED_ITEM_TARGET]"), }; gagvr::FeedItemTarget expectedResponse = new gagvr::FeedItemTarget { ResourceNameAsFeedItemTargetName = gagvr::FeedItemTargetName.FromCustomerFeedItemTarget("[CUSTOMER]", "[FEED_ITEM_TARGET]"), FeedItemAsFeedItemName = gagvr::FeedItemName.FromCustomerFeedItem("[CUSTOMER]", "[FEED_ITEM]"), FeedItemTargetType = gagve::FeedItemTargetTypeEnum.Types.FeedItemTargetType.Criterion, CampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"), AdGroupAsAdGroupName = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER]", "[AD_GROUP]"), FeedItemTargetId = -5234855566520350663L, Keyword = new gagvc::KeywordInfo(), GeoTargetConstantAsGeoTargetConstantName = gagvr::GeoTargetConstantName.FromGeoTargetConstant("[GEO_TARGET_CONSTANT]"), Device = gagve::FeedItemTargetDeviceEnum.Types.FeedItemTargetDevice.Mobile, AdSchedule = new gagvc::AdScheduleInfo(), Status = gagve::FeedItemTargetStatusEnum.Types.FeedItemTargetStatus.Enabled, }; mockGrpcClient.Setup(x => x.GetFeedItemTarget(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); FeedItemTargetServiceClient client = new FeedItemTargetServiceClientImpl(mockGrpcClient.Object, null); gagvr::FeedItemTarget response = client.GetFeedItemTarget(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetFeedItemTargetRequestObjectAsync() { moq::Mock <FeedItemTargetService.FeedItemTargetServiceClient> mockGrpcClient = new moq::Mock <FeedItemTargetService.FeedItemTargetServiceClient>(moq::MockBehavior.Strict); GetFeedItemTargetRequest request = new GetFeedItemTargetRequest { ResourceNameAsFeedItemTargetName = gagvr::FeedItemTargetName.FromCustomerFeedFeedItemFeedItemTargetTypeFeedItemTarget("[CUSTOMER_ID]", "[FEED_ID]", "[FEED_ITEM_ID]", "[FEED_ITEM_TARGET_TYPE]", "[FEED_ITEM_TARGET_ID]"), }; gagvr::FeedItemTarget expectedResponse = new gagvr::FeedItemTarget { ResourceNameAsFeedItemTargetName = gagvr::FeedItemTargetName.FromCustomerFeedFeedItemFeedItemTargetTypeFeedItemTarget("[CUSTOMER_ID]", "[FEED_ID]", "[FEED_ITEM_ID]", "[FEED_ITEM_TARGET_TYPE]", "[FEED_ITEM_TARGET_ID]"), FeedItemTargetType = gagve::FeedItemTargetTypeEnum.Types.FeedItemTargetType.Criterion, Keyword = new gagvc::KeywordInfo(), Device = gagve::FeedItemTargetDeviceEnum.Types.FeedItemTargetDevice.Mobile, AdSchedule = new gagvc::AdScheduleInfo(), Status = gagve::FeedItemTargetStatusEnum.Types.FeedItemTargetStatus.Enabled, FeedItemAsFeedItemName = gagvr::FeedItemName.FromCustomerFeedFeedItem("[CUSTOMER_ID]", "[FEED_ID]", "[FEED_ITEM_ID]"), FeedItemTargetId = -5234855566520350663L, CampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"), AdGroupAsAdGroupName = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER_ID]", "[AD_GROUP_ID]"), GeoTargetConstantAsGeoTargetConstantName = gagvr::GeoTargetConstantName.FromCriterion("[CRITERION_ID]"), }; mockGrpcClient.Setup(x => x.GetFeedItemTargetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::FeedItemTarget>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FeedItemTargetServiceClient client = new FeedItemTargetServiceClientImpl(mockGrpcClient.Object, null); gagvr::FeedItemTarget responseCallSettings = await client.GetFeedItemTargetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::FeedItemTarget responseCancellationToken = await client.GetFeedItemTargetAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }