Пример #1
0
        public async Task GetWorkflowTemplateAsync()
        {
            Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            GetWorkflowTemplateRequest expectedRequest = new GetWorkflowTemplateRequest
            {
                WorkflowTemplateName = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
            };
            WorkflowTemplate expectedResponse = new WorkflowTemplate
            {
                Id = "id3355",
                WorkflowTemplateName = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
                Version = 351608024,
            };

            mockGrpcClient.Setup(x => x.GetWorkflowTemplateAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <WorkflowTemplate>(Task.FromResult(expectedResponse), null, null, null, null));
            WorkflowTemplateServiceClient client = new WorkflowTemplateServiceClientImpl(mockGrpcClient.Object, null);
            WorkflowTemplateName          name   = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
            WorkflowTemplate response            = await client.GetWorkflowTemplateAsync(name);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for InstantiateWorkflowTemplate</summary>
        public void InstantiateWorkflowTemplate2()
        {
            // Snippet: InstantiateWorkflowTemplate(WorkflowTemplateName,IDictionary<string, string>,CallSettings)
            // Create client
            WorkflowTemplateServiceClient workflowTemplateServiceClient = WorkflowTemplateServiceClient.Create();
            // Initialize request argument(s)
            WorkflowTemplateName         name       = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
            IDictionary <string, string> parameters = new Dictionary <string, string>();
            // Make the request
            Operation <Empty, WorkflowMetadata> response =
                workflowTemplateServiceClient.InstantiateWorkflowTemplate(name, parameters);

            // Poll until the returned long-running operation is complete
            Operation <Empty, WorkflowMetadata> completedResponse =
                response.PollUntilCompleted();
            // The long-running operation is now complete.

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Empty, WorkflowMetadata> retrievedResponse =
                workflowTemplateServiceClient.PollOnceInstantiateWorkflowTemplate(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // The long-running operation is now complete.
            }
            // End snippet
        }
        /// <summary>Snippet for InstantiateWorkflowTemplateAsync</summary>
        public async Task InstantiateWorkflowTemplateAsync1()
        {
            // Snippet: InstantiateWorkflowTemplateAsync(WorkflowTemplateName,CallSettings)
            // Additional: InstantiateWorkflowTemplateAsync(WorkflowTemplateName,CancellationToken)
            // Create client
            WorkflowTemplateServiceClient workflowTemplateServiceClient = await WorkflowTemplateServiceClient.CreateAsync();

            // Initialize request argument(s)
            WorkflowTemplateName name = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
            // Make the request
            Operation <Empty, WorkflowMetadata> response =
                await workflowTemplateServiceClient.InstantiateWorkflowTemplateAsync(name);

            // Poll until the returned long-running operation is complete
            Operation <Empty, WorkflowMetadata> completedResponse =
                await response.PollUntilCompletedAsync();

            // The long-running operation is now complete.

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Empty, WorkflowMetadata> retrievedResponse =
                await workflowTemplateServiceClient.PollOnceInstantiateWorkflowTemplateAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // The long-running operation is now complete.
            }
            // End snippet
        }
 /// <summary>Snippet for GetWorkflowTemplate</summary>
 public void GetWorkflowTemplate()
 {
     // Snippet: GetWorkflowTemplate(WorkflowTemplateName,CallSettings)
     // Create client
     WorkflowTemplateServiceClient workflowTemplateServiceClient = WorkflowTemplateServiceClient.Create();
     // Initialize request argument(s)
     WorkflowTemplateName name = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
     // Make the request
     WorkflowTemplate response = workflowTemplateServiceClient.GetWorkflowTemplate(name);
     // End snippet
 }
        /// <summary>Snippet for DeleteWorkflowTemplateAsync</summary>
        public async Task DeleteWorkflowTemplateAsync()
        {
            // Snippet: DeleteWorkflowTemplateAsync(WorkflowTemplateName,CallSettings)
            // Additional: DeleteWorkflowTemplateAsync(WorkflowTemplateName,CancellationToken)
            // Create client
            WorkflowTemplateServiceClient workflowTemplateServiceClient = await WorkflowTemplateServiceClient.CreateAsync();

            // Initialize request argument(s)
            WorkflowTemplateName name = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
            // Make the request
            await workflowTemplateServiceClient.DeleteWorkflowTemplateAsync(name);

            // End snippet
        }
        public void DeleteWorkflowTemplateResourceNames()
        {
            moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            DeleteWorkflowTemplateRequest request = new DeleteWorkflowTemplateRequest
            {
                WorkflowTemplateName = WorkflowTemplateName.FromProjectRegionWorkflowTemplate("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteWorkflowTemplate(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            WorkflowTemplateServiceClient client = new WorkflowTemplateServiceClientImpl(mockGrpcClient.Object, null);

            client.DeleteWorkflowTemplate(request.WorkflowTemplateName);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task CreateWorkflowTemplateRequestObjectAsync()
        {
            moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            CreateWorkflowTemplateRequest request = new CreateWorkflowTemplateRequest
            {
                ParentAsRegionName = RegionName.FromProjectRegion("[PROJECT]", "[REGION]"),
                Template           = new WorkflowTemplate(),
            };
            WorkflowTemplate expectedResponse = new WorkflowTemplate
            {
                WorkflowTemplateName = WorkflowTemplateName.FromProjectRegionWorkflowTemplate("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
                Id         = "id74b70bb8",
                Version    = 271578922,
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Placement  = new WorkflowTemplatePlacement(),
                Jobs       = { new OrderedJob(), },
                Parameters =
                {
                    new TemplateParameter(),
                },
                DagTimeout = new wkt::Duration(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task DeleteWorkflowTemplateResourceNamesAsync()
        {
            moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            DeleteWorkflowTemplateRequest request = new DeleteWorkflowTemplateRequest
            {
                WorkflowTemplateName = WorkflowTemplateName.FromProjectRegionWorkflowTemplate("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteWorkflowTemplateAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            WorkflowTemplateServiceClient client = new WorkflowTemplateServiceClientImpl(mockGrpcClient.Object, null);
            await client.DeleteWorkflowTemplateAsync(request.WorkflowTemplateName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            await client.DeleteWorkflowTemplateAsync(request.WorkflowTemplateName, st::CancellationToken.None);

            mockGrpcClient.VerifyAll();
        }
Пример #9
0
        public async Task DeleteWorkflowTemplateAsync()
        {
            Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            DeleteWorkflowTemplateRequest expectedRequest = new DeleteWorkflowTemplateRequest
            {
                WorkflowTemplateName = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
            };
            Empty expectedResponse = new Empty();

            mockGrpcClient.Setup(x => x.DeleteWorkflowTemplateAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null));
            WorkflowTemplateServiceClient client = new WorkflowTemplateServiceClientImpl(mockGrpcClient.Object, null);
            WorkflowTemplateName          name   = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");
            await client.DeleteWorkflowTemplateAsync(name);

            mockGrpcClient.VerifyAll();
        }
Пример #10
0
        public void DeleteWorkflowTemplate()
        {
            Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            DeleteWorkflowTemplateRequest expectedRequest = new DeleteWorkflowTemplateRequest
            {
                WorkflowTemplateName = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
            };
            Empty expectedResponse = new Empty();

            mockGrpcClient.Setup(x => x.DeleteWorkflowTemplate(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            WorkflowTemplateServiceClient client = new WorkflowTemplateServiceClientImpl(mockGrpcClient.Object, null);
            WorkflowTemplateName          name   = new WorkflowTemplateName("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]");

            client.DeleteWorkflowTemplate(name);
            mockGrpcClient.VerifyAll();
        }
        public void GetWorkflowTemplateRequestObject()
        {
            moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new moq::Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetWorkflowTemplateRequest request = new GetWorkflowTemplateRequest
            {
                WorkflowTemplateName = WorkflowTemplateName.FromProjectRegionWorkflowTemplate("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
                Version = 271578922,
            };
            WorkflowTemplate expectedResponse = new WorkflowTemplate
            {
                WorkflowTemplateName = WorkflowTemplateName.FromProjectRegionWorkflowTemplate("[PROJECT]", "[REGION]", "[WORKFLOW_TEMPLATE]"),
                Id         = "id74b70bb8",
                Version    = 271578922,
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Placement  = new WorkflowTemplatePlacement(),
                Jobs       = { new OrderedJob(), },
                Parameters =
                {
                    new TemplateParameter(),
                },
                DagTimeout = new wkt::Duration(),
            };

            mockGrpcClient.Setup(x => x.GetWorkflowTemplate(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            WorkflowTemplateServiceClient client = new WorkflowTemplateServiceClientImpl(mockGrpcClient.Object, null);
            WorkflowTemplate response            = client.GetWorkflowTemplate(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }