コード例 #1
0
        public async stt::Task GetDomainCategoryRequestObjectAsync()
        {
            moq::Mock <DomainCategoryService.DomainCategoryServiceClient> mockGrpcClient = new moq::Mock <DomainCategoryService.DomainCategoryServiceClient>(moq::MockBehavior.Strict);
            GetDomainCategoryRequest request = new GetDomainCategoryRequest
            {
                ResourceNameAsDomainCategoryName = gagvr::DomainCategoryName.FromCustomerDomainCategory("[CUSTOMER]", "[DOMAIN_CATEGORY]"),
            };
            gagvr::DomainCategory expectedResponse = new gagvr::DomainCategory
            {
                ResourceNameAsDomainCategoryName = gagvr::DomainCategoryName.FromCustomerDomainCategory("[CUSTOMER]", "[DOMAIN_CATEGORY]"),
                CampaignAsCampaignName           = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER]", "[CAMPAIGN]"),
                Category                = "category2f35efc4",
                LanguageCode            = "language_code2f6c7160",
                Domain                  = "domaine8825fad",
                CoverageFraction        = -7.485837735521371E+17,
                CategoryRank            = 1518138877595598869L,
                HasChildren             = true,
                RecommendedCpcBidMicros = -6300343548803856813L,
            };

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

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

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
コード例 #2
0
        public async Task GetDomainCategoryAsync2()
        {
            Mock <DomainCategoryService.DomainCategoryServiceClient> mockGrpcClient = new Mock <DomainCategoryService.DomainCategoryServiceClient>(MockBehavior.Strict);
            GetDomainCategoryRequest request = new GetDomainCategoryRequest
            {
                ResourceName = new DomainCategoryName("[CUSTOMER]", "[DOMAIN_CATEGORY]").ToString(),
            };
            DomainCategory expectedResponse = new DomainCategory
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetDomainCategoryAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <DomainCategory>(Task.FromResult(expectedResponse), null, null, null, null));
            DomainCategoryServiceClient client = new DomainCategoryServiceClientImpl(mockGrpcClient.Object, null);
            DomainCategory response            = await client.GetDomainCategoryAsync(request);

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