Exemplo n.º 1
0
        public void AggregatedList()
        {
            moq::Mock <SslCertificates.SslCertificatesClient> mockGrpcClient = new moq::Mock <SslCertificates.SslCertificatesClient>(moq::MockBehavior.Strict);
            AggregatedListSslCertificatesRequest request = new AggregatedListSslCertificatesRequest
            {
                Project = "projectaa6ff846",
            };
            SslCertificateAggregatedList expectedResponse = new SslCertificateAggregatedList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         =
                {
                    {
                        "key8a0b6e3c",
                        new SslCertificatesScopedList()
                    },
                },
                SelfLink     = "self_link7e87f12d",
                Unreachables =
                {
                    "unreachables3ca950ee",
                },
            };

            mockGrpcClient.Setup(x => x.AggregatedList(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            SslCertificatesClient        client   = new SslCertificatesClientImpl(mockGrpcClient.Object, null);
            SslCertificateAggregatedList response = client.AggregatedList(request.Project);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for AggregatedListAsync</summary>
        public async Task AggregatedListRequestObjectAsync()
        {
            // Snippet: AggregatedListAsync(AggregatedListSslCertificatesRequest, CallSettings)
            // Create client
            SslCertificatesClient sslCertificatesClient = await SslCertificatesClient.CreateAsync();

            // Initialize request argument(s)
            AggregatedListSslCertificatesRequest request = new AggregatedListSslCertificatesRequest
            {
                OrderBy              = "",
                Project              = "",
                Filter               = "",
                IncludeAllScopes     = false,
                ReturnPartialSuccess = false,
            };
            // Make the request
            PagedAsyncEnumerable <SslCertificateAggregatedList, KeyValuePair <string, SslCertificatesScopedList> > response = sslCertificatesClient.AggregatedListAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((KeyValuePair <string, SslCertificatesScopedList> 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((SslCertificateAggregatedList page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (KeyValuePair <string, SslCertificatesScopedList> 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 <KeyValuePair <string, SslCertificatesScopedList> > 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 (KeyValuePair <string, SslCertificatesScopedList> 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
        }
Exemplo n.º 3
0
        public async stt::Task AggregatedListRequestObjectAsync()
        {
            moq::Mock <SslCertificates.SslCertificatesClient> mockGrpcClient = new moq::Mock <SslCertificates.SslCertificatesClient>(moq::MockBehavior.Strict);
            AggregatedListSslCertificatesRequest request = new AggregatedListSslCertificatesRequest
            {
                PageToken            = "page_tokenf09e5538",
                MaxResults           = 2806814450U,
                Filter               = "filtere47ac9b2",
                IncludeAllScopes     = false,
                OrderBy              = "order_byb4d33ada",
                Project              = "projectaa6ff846",
                ReturnPartialSuccess = false,
            };
            SslCertificateAggregatedList expectedResponse = new SslCertificateAggregatedList
            {
                Id            = "id74b70bb8",
                Kind          = "kindf7aa39d9",
                Warning       = new Warning(),
                NextPageToken = "next_page_tokendbee0940",
                Items         =
                {
                    {
                        "key8a0b6e3c",
                        new SslCertificatesScopedList()
                    },
                },
                SelfLink     = "self_link7e87f12d",
                Unreachables =
                {
                    "unreachables3ca950ee",
                },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 4
0
 /// <summary>Snippet for AggregatedList</summary>
 public void AggregatedListRequestObject()
 {
     // Snippet: AggregatedList(AggregatedListSslCertificatesRequest, CallSettings)
     // Create client
     SslCertificatesClient sslCertificatesClient = SslCertificatesClient.Create();
     // Initialize request argument(s)
     AggregatedListSslCertificatesRequest request = new AggregatedListSslCertificatesRequest
     {
         PageToken            = "",
         MaxResults           = 0U,
         Filter               = "",
         IncludeAllScopes     = false,
         OrderBy              = "",
         Project              = "",
         ReturnPartialSuccess = false,
     };
     // Make the request
     SslCertificateAggregatedList response = sslCertificatesClient.AggregatedList(request);
     // End snippet
 }
Exemplo n.º 5
0
        /// <summary>Snippet for AggregatedListAsync</summary>
        public async Task AggregatedListRequestObjectAsync()
        {
            // Snippet: AggregatedListAsync(AggregatedListSslCertificatesRequest, CallSettings)
            // Additional: AggregatedListAsync(AggregatedListSslCertificatesRequest, CancellationToken)
            // Create client
            SslCertificatesClient sslCertificatesClient = await SslCertificatesClient.CreateAsync();

            // Initialize request argument(s)
            AggregatedListSslCertificatesRequest request = new AggregatedListSslCertificatesRequest
            {
                PageToken            = "",
                MaxResults           = 0U,
                Filter               = "",
                IncludeAllScopes     = false,
                OrderBy              = "",
                Project              = "",
                ReturnPartialSuccess = false,
            };
            // Make the request
            SslCertificateAggregatedList response = await sslCertificatesClient.AggregatedListAsync(request);

            // End snippet
        }