示例#1
0
        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.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.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();
        }
        public async Task GetFeedItemTargetAsync2()
        {
            Mock <FeedItemTargetService.FeedItemTargetServiceClient> mockGrpcClient = new Mock <FeedItemTargetService.FeedItemTargetServiceClient>(MockBehavior.Strict);
            GetFeedItemTargetRequest request = new GetFeedItemTargetRequest
            {
                ResourceName = new FeedItemTargetName("[CUSTOMER]", "[FEED_ITEM_TARGET]").ToString(),
            };
            FeedItemTarget expectedResponse = new FeedItemTarget
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetFeedItemTargetAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <FeedItemTarget>(Task.FromResult(expectedResponse), null, null, null, null));
            FeedItemTargetServiceClient client = new FeedItemTargetServiceClientImpl(mockGrpcClient.Object, null);
            FeedItemTarget response            = await client.GetFeedItemTargetAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }