Exemplo n.º 1
0
        public async stt::Task GetExtensionFeedItemRequestObjectAsync()
        {
            moq::Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient> mockGrpcClient = new moq::Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient>(moq::MockBehavior.Strict);
            GetExtensionFeedItemRequest request = new GetExtensionFeedItemRequest
            {
                ResourceNameAsExtensionFeedItemName = gagvr::ExtensionFeedItemName.FromCustomerFeedItem("[CUSTOMER_ID]", "[FEED_ITEM_ID]"),
            };
            gagvr::ExtensionFeedItem expectedResponse = new gagvr::ExtensionFeedItem
            {
                ResourceNameAsExtensionFeedItemName = gagvr::ExtensionFeedItemName.FromCustomerFeedItem("[CUSTOMER_ID]", "[FEED_ITEM_ID]"),
                SitelinkFeedItem          = new gagvc::SitelinkFeedItem(),
                StructuredSnippetFeedItem = new gagvc::StructuredSnippetFeedItem(),
                Status                    = gagve::FeedItemStatusEnum.Types.FeedItemStatus.Enabled,
                AppFeedItem               = new gagvc::AppFeedItem(),
                CallFeedItem              = new gagvc::CallFeedItem(),
                CalloutFeedItem           = new gagvc::CalloutFeedItem(),
                TextMessageFeedItem       = new gagvc::TextMessageFeedItem(),
                PriceFeedItem             = new gagvc::PriceFeedItem(),
                PromotionFeedItem         = new gagvc::PromotionFeedItem(),
                ExtensionType             = gagve::ExtensionTypeEnum.Types.ExtensionType.Promotion,
                LocationFeedItem          = new gagvc::LocationFeedItem(),
                AffiliateLocationFeedItem = new gagvc::AffiliateLocationFeedItem(),
                AdSchedules               =
                {
                    new gagvc::AdScheduleInfo(),
                },
                Device               = gagve::FeedItemTargetDeviceEnum.Types.FeedItemTargetDevice.Mobile,
                TargetedKeyword      = new gagvc::KeywordInfo(),
                HotelCalloutFeedItem = new gagvc::HotelCalloutFeedItem(),
                Id            = -6774108720365892680L,
                StartDateTime = "start_date_timeea924cb1",
                EndDateTime   = "end_date_timea95363f3",
                TargetedCampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"),
                TargetedAdGroupAsAdGroupName   = gagvr::AdGroupName.FromCustomerAdGroup("[CUSTOMER_ID]", "[AD_GROUP_ID]"),
                TargetedGeoTargetConstantAsGeoTargetConstantName = gagvr::GeoTargetConstantName.FromCriterion("[CRITERION_ID]"),
                ImageFeedItem = new gagvc::ImageFeedItem(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public async Task GetExtensionFeedItemAsync2()
        {
            Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient> mockGrpcClient = new Mock <ExtensionFeedItemService.ExtensionFeedItemServiceClient>(MockBehavior.Strict);
            GetExtensionFeedItemRequest request = new GetExtensionFeedItemRequest
            {
                ResourceName = new ExtensionFeedItemName("[CUSTOMER]", "[EXTENSION_FEED_ITEM]").ToString(),
            };
            ExtensionFeedItem expectedResponse = new ExtensionFeedItem
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetExtensionFeedItemAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <ExtensionFeedItem>(Task.FromResult(expectedResponse), null, null, null, null));
            ExtensionFeedItemServiceClient client = new ExtensionFeedItemServiceClientImpl(mockGrpcClient.Object, null);
            ExtensionFeedItem response            = await client.GetExtensionFeedItemAsync(request);

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