Example #1
0
        public void GetWebpageView()
        {
            moq::Mock <WebpageViewService.WebpageViewServiceClient> mockGrpcClient = new moq::Mock <WebpageViewService.WebpageViewServiceClient>(moq::MockBehavior.Strict);
            GetWebpageViewRequest request = new GetWebpageViewRequest
            {
                ResourceNameAsWebpageViewName = gagvr::WebpageViewName.FromCustomerAdGroupCriterion("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]"),
            };
            gagvr::WebpageView expectedResponse = new gagvr::WebpageView
            {
                ResourceNameAsWebpageViewName = gagvr::WebpageViewName.FromCustomerAdGroupCriterion("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]"),
            };

            mockGrpcClient.Setup(x => x.GetWebpageView(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            WebpageViewServiceClient client   = new WebpageViewServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::WebpageView       response = client.GetWebpageView(request.ResourceName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #2
0
        public async stt::Task GetWebpageViewAsync()
        {
            moq::Mock <WebpageViewService.WebpageViewServiceClient> mockGrpcClient = new moq::Mock <WebpageViewService.WebpageViewServiceClient>(moq::MockBehavior.Strict);
            GetWebpageViewRequest request = new GetWebpageViewRequest
            {
                ResourceNameAsWebpageViewName = gagvr::WebpageViewName.FromCustomerAdGroupCriterion("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]"),
            };
            gagvr::WebpageView expectedResponse = new gagvr::WebpageView
            {
                ResourceNameAsWebpageViewName = gagvr::WebpageViewName.FromCustomerAdGroupCriterion("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]"),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }