예제 #1
0
        public async stt::Task ListAsync()
        {
            moq::Mock <GlobalOrganizationOperations.GlobalOrganizationOperationsClient> mockGrpcClient = new moq::Mock <GlobalOrganizationOperations.GlobalOrganizationOperationsClient>(moq::MockBehavior.Strict);
            ListGlobalOrganizationOperationsRequest request = new ListGlobalOrganizationOperationsRequest {
            };
            OperationList expectedResponse = new OperationList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         = { new Operation(), },
                SelfLink      = "self_link7e87f12d",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            OperationList responseCancellationToken = await client.ListAsync(st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
예제 #2
0
        public async stt::Task ListRequestObjectAsync()
        {
            moq::Mock <GlobalOrganizationOperations.GlobalOrganizationOperationsClient> mockGrpcClient = new moq::Mock <GlobalOrganizationOperations.GlobalOrganizationOperationsClient>(moq::MockBehavior.Strict);
            ListGlobalOrganizationOperationsRequest request = new ListGlobalOrganizationOperationsRequest
            {
                PageToken            = "page_tokenf09e5538",
                MaxResults           = 2806814450U,
                Filter               = "filtere47ac9b2",
                OrderBy              = "order_byb4d33ada",
                ParentId             = "parent_id8279e36b",
                ReturnPartialSuccess = false,
            };
            OperationList expectedResponse = new OperationList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         = { new Operation(), },
                SelfLink      = "self_link7e87f12d",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            OperationList responseCancellationToken = await client.ListAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for ListAsync</summary>
        public async Task ListRequestObjectAsync()
        {
            // Snippet: ListAsync(ListGlobalOrganizationOperationsRequest, CallSettings)
            // Create client
            GlobalOrganizationOperationsClient globalOrganizationOperationsClient = await GlobalOrganizationOperationsClient.CreateAsync();

            // Initialize request argument(s)
            ListGlobalOrganizationOperationsRequest request = new ListGlobalOrganizationOperationsRequest
            {
                OrderBy              = "",
                Filter               = "",
                ParentId             = "",
                ReturnPartialSuccess = false,
            };
            // Make the request
            PagedAsyncEnumerable <OperationList, Operation> response = globalOrganizationOperationsClient.ListAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Operation item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((OperationList page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Operation item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <Operation> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Operation item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
 /// <summary>Snippet for List</summary>
 public void ListRequestObject()
 {
     // Snippet: List(ListGlobalOrganizationOperationsRequest, CallSettings)
     // Create client
     GlobalOrganizationOperationsClient globalOrganizationOperationsClient = GlobalOrganizationOperationsClient.Create();
     // Initialize request argument(s)
     ListGlobalOrganizationOperationsRequest request = new ListGlobalOrganizationOperationsRequest
     {
         PageToken            = "",
         MaxResults           = 0U,
         OrderBy              = "",
         Filter               = "",
         ParentId             = "",
         ReturnPartialSuccess = false,
     };
     // Make the request
     OperationList response = globalOrganizationOperationsClient.List(request);
     // End snippet
 }
예제 #5
0
        public void List()
        {
            moq::Mock <GlobalOrganizationOperations.GlobalOrganizationOperationsClient> mockGrpcClient = new moq::Mock <GlobalOrganizationOperations.GlobalOrganizationOperationsClient>(moq::MockBehavior.Strict);
            ListGlobalOrganizationOperationsRequest request = new ListGlobalOrganizationOperationsRequest {
            };
            OperationList expectedResponse = new OperationList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         = { new Operation(), },
                SelfLink      = "self_link7e87f12d",
            };

            mockGrpcClient.Setup(x => x.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            GlobalOrganizationOperationsClient client = new GlobalOrganizationOperationsClientImpl(mockGrpcClient.Object, null);
            OperationList response = client.List();

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for ListAsync</summary>
        public async Task ListRequestObjectAsync()
        {
            // Snippet: ListAsync(ListGlobalOrganizationOperationsRequest, CallSettings)
            // Additional: ListAsync(ListGlobalOrganizationOperationsRequest, CancellationToken)
            // Create client
            GlobalOrganizationOperationsClient globalOrganizationOperationsClient = await GlobalOrganizationOperationsClient.CreateAsync();

            // Initialize request argument(s)
            ListGlobalOrganizationOperationsRequest request = new ListGlobalOrganizationOperationsRequest
            {
                PageToken            = "",
                MaxResults           = 0U,
                OrderBy              = "",
                Filter               = "",
                ParentId             = "",
                ReturnPartialSuccess = false,
            };
            // Make the request
            OperationList response = await globalOrganizationOperationsClient.ListAsync(request);

            // End snippet
        }