public async stt::Task ListAsync() { moq::Mock <ZoneOperations.ZoneOperationsClient> mockGrpcClient = new moq::Mock <ZoneOperations.ZoneOperationsClient>(moq::MockBehavior.Strict); ListZoneOperationsRequest request = new ListZoneOperationsRequest { Zone = "zone255f4ea8", Project = "projectaa6ff846", }; 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)); ZoneOperationsClient client = new ZoneOperationsClientImpl(mockGrpcClient.Object, null); OperationList responseCallSettings = await client.ListAsync(request.Project, request.Zone, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); OperationList responseCancellationToken = await client.ListAsync(request.Project, request.Zone, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void List() { moq::Mock <ZoneOperations.ZoneOperationsClient> mockGrpcClient = new moq::Mock <ZoneOperations.ZoneOperationsClient>(moq::MockBehavior.Strict); ListZoneOperationsRequest request = new ListZoneOperationsRequest { Zone = "zone255f4ea8", Project = "projectaa6ff846", }; 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); ZoneOperationsClient client = new ZoneOperationsClientImpl(mockGrpcClient.Object, null); OperationList response = client.List(request.Project, request.Zone); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void ListRequestObject() { moq::Mock <ZoneOperations.ZoneOperationsClient> mockGrpcClient = new moq::Mock <ZoneOperations.ZoneOperationsClient>(moq::MockBehavior.Strict); ListZoneOperationsRequest request = new ListZoneOperationsRequest { Zone = "zone255f4ea8", PageToken = "page_tokenf09e5538", MaxResults = 2806814450U, Filter = "filtere47ac9b2", OrderBy = "order_byb4d33ada", Project = "projectaa6ff846", 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.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ZoneOperationsClient client = new ZoneOperationsClientImpl(mockGrpcClient.Object, null); OperationList response = client.List(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for ListAsync</summary> public async Task ListRequestObjectAsync() { // Snippet: ListAsync(ListZoneOperationsRequest, CallSettings) // Create client ZoneOperationsClient zoneOperationsClient = await ZoneOperationsClient.CreateAsync(); // Initialize request argument(s) ListZoneOperationsRequest request = new ListZoneOperationsRequest { Zone = "", OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request PagedAsyncEnumerable <OperationList, Operation> response = zoneOperationsClient.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(ListZoneOperationsRequest, CallSettings) // Create client ZoneOperationsClient zoneOperationsClient = ZoneOperationsClient.Create(); // Initialize request argument(s) ListZoneOperationsRequest request = new ListZoneOperationsRequest { Zone = "", PageToken = "", MaxResults = 0U, OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request OperationList response = zoneOperationsClient.List(request); // End snippet }
/// <summary>Snippet for ListAsync</summary> public async Task ListRequestObjectAsync() { // Snippet: ListAsync(ListZoneOperationsRequest, CallSettings) // Additional: ListAsync(ListZoneOperationsRequest, CancellationToken) // Create client ZoneOperationsClient zoneOperationsClient = await ZoneOperationsClient.CreateAsync(); // Initialize request argument(s) ListZoneOperationsRequest request = new ListZoneOperationsRequest { Zone = "", PageToken = "", MaxResults = 0U, OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request OperationList response = await zoneOperationsClient.ListAsync(request); // End snippet }