public void List() { moq::Mock <TargetVpnGateways.TargetVpnGatewaysClient> mockGrpcClient = new moq::Mock <TargetVpnGateways.TargetVpnGatewaysClient>(moq::MockBehavior.Strict); ListTargetVpnGatewaysRequest request = new ListTargetVpnGatewaysRequest { Region = "regionedb20d96", Project = "projectaa6ff846", }; TargetVpnGatewayList expectedResponse = new TargetVpnGatewayList { Id = "id74b70bb8", Kind = "kindf7aa39d9", Warning = new Warning(), NextPageToken = "next_page_tokendbee0940", Items = { new TargetVpnGateway(), }, SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TargetVpnGatewaysClient client = new TargetVpnGatewaysClientImpl(mockGrpcClient.Object, null); TargetVpnGatewayList response = client.List(request.Project, request.Region); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task ListAsync() { moq::Mock <TargetVpnGateways.TargetVpnGatewaysClient> mockGrpcClient = new moq::Mock <TargetVpnGateways.TargetVpnGatewaysClient>(moq::MockBehavior.Strict); ListTargetVpnGatewaysRequest request = new ListTargetVpnGatewaysRequest { Region = "regionedb20d96", Project = "projectaa6ff846", }; TargetVpnGatewayList expectedResponse = new TargetVpnGatewayList { Id = "id74b70bb8", Kind = "kindf7aa39d9", Warning = new Warning(), NextPageToken = "next_page_tokendbee0940", Items = { new TargetVpnGateway(), }, SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.ListAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <TargetVpnGatewayList>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TargetVpnGatewaysClient client = new TargetVpnGatewaysClientImpl(mockGrpcClient.Object, null); TargetVpnGatewayList responseCallSettings = await client.ListAsync(request.Project, request.Region, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); TargetVpnGatewayList responseCancellationToken = await client.ListAsync(request.Project, request.Region, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void ListRequestObject() { moq::Mock <TargetVpnGateways.TargetVpnGatewaysClient> mockGrpcClient = new moq::Mock <TargetVpnGateways.TargetVpnGatewaysClient>(moq::MockBehavior.Strict); ListTargetVpnGatewaysRequest request = new ListTargetVpnGatewaysRequest { PageToken = "page_tokenf09e5538", MaxResults = 2806814450U, Region = "regionedb20d96", OrderBy = "order_byb4d33ada", Project = "projectaa6ff846", Filter = "filtere47ac9b2", ReturnPartialSuccess = false, }; TargetVpnGatewayList expectedResponse = new TargetVpnGatewayList { Id = "id74b70bb8", Kind = "kindf7aa39d9", Warning = new Warning(), NextPageToken = "next_page_tokendbee0940", Items = { new TargetVpnGateway(), }, SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TargetVpnGatewaysClient client = new TargetVpnGatewaysClientImpl(mockGrpcClient.Object, null); TargetVpnGatewayList response = client.List(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for ListAsync</summary> public async Task ListRequestObjectAsync() { // Snippet: ListAsync(ListTargetVpnGatewaysRequest, CallSettings) // Create client TargetVpnGatewaysClient targetVpnGatewaysClient = await TargetVpnGatewaysClient.CreateAsync(); // Initialize request argument(s) ListTargetVpnGatewaysRequest request = new ListTargetVpnGatewaysRequest { Region = "", OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request PagedAsyncEnumerable <TargetVpnGatewayList, TargetVpnGateway> response = targetVpnGatewaysClient.ListAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((TargetVpnGateway 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((TargetVpnGatewayList page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (TargetVpnGateway 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 <TargetVpnGateway> 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 (TargetVpnGateway 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(ListTargetVpnGatewaysRequest, CallSettings) // Create client TargetVpnGatewaysClient targetVpnGatewaysClient = TargetVpnGatewaysClient.Create(); // Initialize request argument(s) ListTargetVpnGatewaysRequest request = new ListTargetVpnGatewaysRequest { PageToken = "", MaxResults = 0U, Region = "", OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request TargetVpnGatewayList response = targetVpnGatewaysClient.List(request); // End snippet }
/// <summary>Snippet for ListAsync</summary> public async Task ListRequestObjectAsync() { // Snippet: ListAsync(ListTargetVpnGatewaysRequest, CallSettings) // Additional: ListAsync(ListTargetVpnGatewaysRequest, CancellationToken) // Create client TargetVpnGatewaysClient targetVpnGatewaysClient = await TargetVpnGatewaysClient.CreateAsync(); // Initialize request argument(s) ListTargetVpnGatewaysRequest request = new ListTargetVpnGatewaysRequest { PageToken = "", MaxResults = 0U, Region = "", OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request TargetVpnGatewayList response = await targetVpnGatewaysClient.ListAsync(request); // End snippet }
/// <summary> /// Retrieves a list of target VPN gateways available to the specified project and region. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>A Task containing the RPC response.</returns> public override stt::Task <TargetVpnGatewayList> ListAsync(ListTargetVpnGatewaysRequest request, gaxgrpc::CallSettings callSettings = null) { Modify_ListTargetVpnGatewaysRequest(ref request, ref callSettings); return(_callList.Async(request, callSettings)); }
partial void Modify_ListTargetVpnGatewaysRequest(ref ListTargetVpnGatewaysRequest request, ref gaxgrpc::CallSettings settings);
/// <summary> /// Retrieves a list of target VPN gateways available to the specified project and region. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param> /// <returns>A Task containing the RPC response.</returns> public virtual stt::Task <TargetVpnGatewayList> ListAsync(ListTargetVpnGatewaysRequest request, st::CancellationToken cancellationToken) => ListAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
/// <summary> /// Retrieves a list of target VPN gateways available to the specified project and region. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>A Task containing the RPC response.</returns> public virtual stt::Task <TargetVpnGatewayList> ListAsync(ListTargetVpnGatewaysRequest request, gaxgrpc::CallSettings callSettings = null) => throw new sys::NotImplementedException();