Esempio n. 1
0
        public async stt::Task ListAsync()
        {
            moq::Mock <RegionNotificationEndpoints.RegionNotificationEndpointsClient> mockGrpcClient = new moq::Mock <RegionNotificationEndpoints.RegionNotificationEndpointsClient>(moq::MockBehavior.Strict);
            ListRegionNotificationEndpointsRequest request = new ListRegionNotificationEndpointsRequest
            {
                Region  = "regionedb20d96",
                Project = "projectaa6ff846",
            };
            NotificationEndpointList expectedResponse = new NotificationEndpointList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         =
                {
                    new NotificationEndpoint(),
                },
                SelfLink = "self_link7e87f12d",
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 2
0
        public void List()
        {
            moq::Mock <RegionNotificationEndpoints.RegionNotificationEndpointsClient> mockGrpcClient = new moq::Mock <RegionNotificationEndpoints.RegionNotificationEndpointsClient>(moq::MockBehavior.Strict);
            ListRegionNotificationEndpointsRequest request = new ListRegionNotificationEndpointsRequest
            {
                Region  = "regionedb20d96",
                Project = "projectaa6ff846",
            };
            NotificationEndpointList expectedResponse = new NotificationEndpointList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         =
                {
                    new NotificationEndpoint(),
                },
                SelfLink = "self_link7e87f12d",
            };

            mockGrpcClient.Setup(x => x.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            RegionNotificationEndpointsClient client   = new RegionNotificationEndpointsClientImpl(mockGrpcClient.Object, null);
            NotificationEndpointList          response = client.List(request.Project, request.Region);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 3
0
        public void ListRequestObject()
        {
            moq::Mock <RegionNotificationEndpoints.RegionNotificationEndpointsClient> mockGrpcClient = new moq::Mock <RegionNotificationEndpoints.RegionNotificationEndpointsClient>(moq::MockBehavior.Strict);
            ListRegionNotificationEndpointsRequest request = new ListRegionNotificationEndpointsRequest
            {
                PageToken            = "page_tokenf09e5538",
                MaxResults           = 2806814450U,
                Region               = "regionedb20d96",
                OrderBy              = "order_byb4d33ada",
                Project              = "projectaa6ff846",
                Filter               = "filtere47ac9b2",
                ReturnPartialSuccess = false,
            };
            NotificationEndpointList expectedResponse = new NotificationEndpointList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         =
                {
                    new NotificationEndpoint(),
                },
                SelfLink = "self_link7e87f12d",
            };

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

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

            // Initialize request argument(s)
            ListRegionNotificationEndpointsRequest request = new ListRegionNotificationEndpointsRequest
            {
                Region  = "",
                OrderBy = "",
                Project = "",
                Filter  = "",
                ReturnPartialSuccess = false,
            };
            // Make the request
            PagedAsyncEnumerable <NotificationEndpointList, NotificationEndpoint> response = regionNotificationEndpointsClient.ListAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((NotificationEndpoint 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((NotificationEndpointList page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (NotificationEndpoint 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 <NotificationEndpoint> 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 (NotificationEndpoint 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
        }
Esempio n. 5
0
 /// <summary>Snippet for List</summary>
 public void ListRequestObject()
 {
     // Snippet: List(ListRegionNotificationEndpointsRequest, CallSettings)
     // Create client
     RegionNotificationEndpointsClient regionNotificationEndpointsClient = RegionNotificationEndpointsClient.Create();
     // Initialize request argument(s)
     ListRegionNotificationEndpointsRequest request = new ListRegionNotificationEndpointsRequest
     {
         PageToken            = "",
         MaxResults           = 0U,
         Region               = "",
         OrderBy              = "",
         Project              = "",
         Filter               = "",
         ReturnPartialSuccess = false,
     };
     // Make the request
     NotificationEndpointList response = regionNotificationEndpointsClient.List(request);
     // End snippet
 }
Esempio n. 6
0
        /// <summary>Snippet for ListAsync</summary>
        public async Task ListRequestObjectAsync()
        {
            // Snippet: ListAsync(ListRegionNotificationEndpointsRequest, CallSettings)
            // Additional: ListAsync(ListRegionNotificationEndpointsRequest, CancellationToken)
            // Create client
            RegionNotificationEndpointsClient regionNotificationEndpointsClient = await RegionNotificationEndpointsClient.CreateAsync();

            // Initialize request argument(s)
            ListRegionNotificationEndpointsRequest request = new ListRegionNotificationEndpointsRequest
            {
                PageToken            = "",
                MaxResults           = 0U,
                Region               = "",
                OrderBy              = "",
                Project              = "",
                Filter               = "",
                ReturnPartialSuccess = false,
            };
            // Make the request
            NotificationEndpointList response = await regionNotificationEndpointsClient.ListAsync(request);

            // End snippet
        }