public async stt::Task GetEnvironmentRequestObjectAsync() { moq::Mock <NotebookService.NotebookServiceClient> mockGrpcClient = new moq::Mock <NotebookService.NotebookServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetEnvironmentRequest request = new GetEnvironmentRequest { Name = "name1c9368b0", }; Environment expectedResponse = new Environment { EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), DisplayName = "display_name137f65c2", Description = "description2cf9da67", VmImage = new VmImage(), ContainerImage = new ContainerImage(), PostStartupScript = "post_startup_script0d185c71", CreateTime = new wkt::Timestamp(), }; mockGrpcClient.Setup(x => x.GetEnvironmentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Environment>(stt::Task.FromResult(expectedResponse), null, null, null, null)); NotebookServiceClient client = new NotebookServiceClientImpl(mockGrpcClient.Object, null); Environment responseCallSettings = await client.GetEnvironmentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Environment responseCancellationToken = await client.GetEnvironmentAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task GetEnvironmentRequestObjectAsync() { moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict); GetEnvironmentRequest request = new GetEnvironmentRequest { EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), }; Environment expectedResponse = new Environment { EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), Description = "description2cf9da67", AgentVersionAsVersionName = VersionName.FromProjectVersion("[PROJECT]", "[VERSION]"), State = Environment.Types.State.Loading, UpdateTime = new wkt::Timestamp(), TextToSpeechSettings = new TextToSpeechSettings(), Fulfillment = new Fulfillment(), }; mockGrpcClient.Setup(x => x.GetEnvironmentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Environment>(stt::Task.FromResult(expectedResponse), null, null, null, null)); EnvironmentsClient client = new EnvironmentsClientImpl(mockGrpcClient.Object, null); Environment responseCallSettings = await client.GetEnvironmentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Environment responseCancellationToken = await client.GetEnvironmentAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void CreateEnvironmentRequestObject() { moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict); CreateEnvironmentRequest request = new CreateEnvironmentRequest { ParentAsAgentName = AgentName.FromProject("[PROJECT]"), Environment = new Environment(), EnvironmentId = "environment_id26e3069e", }; Environment expectedResponse = new Environment { EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), Description = "description2cf9da67", AgentVersionAsVersionName = VersionName.FromProjectVersion("[PROJECT]", "[VERSION]"), State = Environment.Types.State.Loading, UpdateTime = new wkt::Timestamp(), TextToSpeechSettings = new TextToSpeechSettings(), Fulfillment = new Fulfillment(), }; mockGrpcClient.Setup(x => x.CreateEnvironment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); EnvironmentsClient client = new EnvironmentsClientImpl(mockGrpcClient.Object, null); Environment response = client.CreateEnvironment(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void UpdateEnvironmentRequestObject() { moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict); UpdateEnvironmentRequest request = new UpdateEnvironmentRequest { Environment = new Environment(), UpdateMask = new wkt::FieldMask(), AllowLoadToDraftAndDiscardChanges = true, }; Environment expectedResponse = new Environment { EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), Description = "description2cf9da67", AgentVersionAsVersionName = VersionName.FromProjectVersion("[PROJECT]", "[VERSION]"), State = Environment.Types.State.Loading, UpdateTime = new wkt::Timestamp(), TextToSpeechSettings = new TextToSpeechSettings(), Fulfillment = new Fulfillment(), }; mockGrpcClient.Setup(x => x.UpdateEnvironment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); EnvironmentsClient client = new EnvironmentsClientImpl(mockGrpcClient.Object, null); Environment response = client.UpdateEnvironment(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetEnvironment</summary> public void GetEnvironmentRequestObject() { // Snippet: GetEnvironment(GetEnvironmentRequest, CallSettings) // Create client EnvironmentsClient environmentsClient = EnvironmentsClient.Create(); // Initialize request argument(s) GetEnvironmentRequest request = new GetEnvironmentRequest { EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), }; // Make the request gcdv::Environment response = environmentsClient.GetEnvironment(request); // End snippet }
/// <summary>Snippet for DeleteEnvironment</summary> public void DeleteEnvironmentRequestObject() { // Snippet: DeleteEnvironment(DeleteEnvironmentRequest, CallSettings) // Create client EnvironmentsClient environmentsClient = EnvironmentsClient.Create(); // Initialize request argument(s) DeleteEnvironmentRequest request = new DeleteEnvironmentRequest { EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), }; // Make the request environmentsClient.DeleteEnvironment(request); // End snippet }
/// <summary>Snippet for GetEnvironmentHistoryAsync</summary> public async Task GetEnvironmentHistoryRequestObjectAsync() { // Snippet: GetEnvironmentHistoryAsync(GetEnvironmentHistoryRequest, CallSettings) // Create client EnvironmentsClient environmentsClient = await EnvironmentsClient.CreateAsync(); // Initialize request argument(s) GetEnvironmentHistoryRequest request = new GetEnvironmentHistoryRequest { ParentAsEnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), }; // Make the request PagedAsyncEnumerable <EnvironmentHistory, EnvironmentHistory.Types.Entry> response = environmentsClient.GetEnvironmentHistoryAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((EnvironmentHistory.Types.Entry 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((EnvironmentHistory page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (EnvironmentHistory.Types.Entry 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 <EnvironmentHistory.Types.Entry> 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 (EnvironmentHistory.Types.Entry 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 }
public void DeleteEnvironmentRequestObject() { moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict); DeleteEnvironmentRequest request = new DeleteEnvironmentRequest { EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteEnvironment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); EnvironmentsClient client = new EnvironmentsClientImpl(mockGrpcClient.Object, null); client.DeleteEnvironment(request); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for DeleteEnvironmentAsync</summary> public async Task DeleteEnvironmentRequestObjectAsync() { // Snippet: DeleteEnvironmentAsync(DeleteEnvironmentRequest, CallSettings) // Additional: DeleteEnvironmentAsync(DeleteEnvironmentRequest, CancellationToken) // Create client EnvironmentsClient environmentsClient = await EnvironmentsClient.CreateAsync(); // Initialize request argument(s) DeleteEnvironmentRequest request = new DeleteEnvironmentRequest { EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), }; // Make the request await environmentsClient.DeleteEnvironmentAsync(request); // End snippet }
public async stt::Task DeleteEnvironmentRequestObjectAsync() { moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict); DeleteEnvironmentRequest request = new DeleteEnvironmentRequest { EnvironmentName = EnvironmentName.FromProjectEnvironment("[PROJECT]", "[ENVIRONMENT]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteEnvironmentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); EnvironmentsClient client = new EnvironmentsClientImpl(mockGrpcClient.Object, null); await client.DeleteEnvironmentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteEnvironmentAsync(request, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }