コード例 #1
0
        public async stt::Task GetAssetRequestObjectAsync()
        {
            moq::Mock <AssetService.AssetServiceClient> mockGrpcClient = new moq::Mock <AssetService.AssetServiceClient>(moq::MockBehavior.Strict);
            GetAssetRequest request = new GetAssetRequest
            {
                ResourceNameAsAssetName = gagvr::AssetName.FromCustomerAsset("[CUSTOMER]", "[ASSET]"),
            };
            gagvr::Asset expectedResponse = new gagvr::Asset
            {
                ResourceNameAsAssetName = gagvr::AssetName.FromCustomerAsset("[CUSTOMER]", "[ASSET]"),
                Id                = -6774108720365892680L,
                AssetName         = gagvr::AssetName.FromCustomerAsset("[CUSTOMER]", "[ASSET]"),
                Type              = gagve::AssetTypeEnum.Types.AssetType.Image,
                YoutubeVideoAsset = new gagvc::YoutubeVideoAsset(),
                MediaBundleAsset  = new gagvc::MediaBundleAsset(),
                ImageAsset        = new gagvc::ImageAsset(),
                TextAsset         = new gagvc::TextAsset(),
                BookOnGoogleAsset = new gagvc::BookOnGoogleAsset(),
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::Asset responseCancellationToken = await client.GetAssetAsync(request, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
        public async stt::Task GetAssetRequestObjectAsync()
        {
            moq::Mock <AssetService.AssetServiceClient> mockGrpcClient = new moq::Mock <AssetService.AssetServiceClient>(moq::MockBehavior.Strict);
            GetAssetRequest request = new GetAssetRequest
            {
                ResourceNameAsAssetName = gagvr::AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]"),
            };
            gagvr::Asset expectedResponse = new gagvr::Asset
            {
                ResourceNameAsAssetName = gagvr::AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]"),
                Type = gagve::AssetTypeEnum.Types.AssetType.LeadForm,
                YoutubeVideoAsset = new gagvc::YoutubeVideoAsset(),
                MediaBundleAsset  = new gagvc::MediaBundleAsset(),
                ImageAsset        = new gagvc::ImageAsset(),
                TextAsset         = new gagvc::TextAsset(),
                LeadFormAsset     = new gagvc::LeadFormAsset(),
                BookOnGoogleAsset = new gagvc::BookOnGoogleAsset(),
                Id            = -6774108720365892680L,
                AssetName     = gagvr::AssetName.FromCustomerAsset("[CUSTOMER_ID]", "[ASSET_ID]"),
                PolicySummary = new gagvr::AssetPolicySummary(),
                FinalUrls     =
                {
                    "final_urls3ed0b71b",
                },
                PromotionAsset  = new gagvc::PromotionAsset(),
                FinalMobileUrls =
                {
                    "final_mobile_urlsf4131aa0",
                },
                TrackingUrlTemplate = "tracking_url_template157f152a",
                UrlCustomParameters =
                {
                    new gagvc::CustomParameter(),
                },
                FinalUrlSuffix         = "final_url_suffix046ed37a",
                CalloutAsset           = new gagvc::CalloutAsset(),
                StructuredSnippetAsset = new gagvc::StructuredSnippetAsset(),
                SitelinkAsset          = new gagvc::SitelinkAsset(),
                PageFeedAsset          = new gagvc::PageFeedAsset(),
                DynamicEducationAsset  = new gagvc::DynamicEducationAsset(),
                MobileAppAsset         = new gagvc::MobileAppAsset(),
                HotelCalloutAsset      = new gagvc::HotelCalloutAsset(),
                CallAsset         = new gagvc::CallAsset(),
                PriceAsset        = new gagvc::PriceAsset(),
                CallToActionAsset = new gagvc::CallToActionAsset(),
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::Asset responseCancellationToken = await client.GetAssetAsync(request, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #3
0
        public async Task GetAssetAsync2()
        {
            Mock <AssetService.AssetServiceClient> mockGrpcClient = new Mock <AssetService.AssetServiceClient>(MockBehavior.Strict);
            GetAssetRequest request = new GetAssetRequest
            {
                ResourceName = new AssetName("[CUSTOMER]", "[ASSET]").ToString(),
            };
            Asset expectedResponse = new Asset
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetAssetAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Asset>(Task.FromResult(expectedResponse), null, null, null, null));
            AssetServiceClient client = new AssetServiceClientImpl(mockGrpcClient.Object, null);
            Asset response            = await client.GetAssetAsync(request);

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