Beispiel #1
0
        public void CreateExecution()
        {
            moq::Mock <Executions.ExecutionsClient> mockGrpcClient = new moq::Mock <Executions.ExecutionsClient>(moq::MockBehavior.Strict);
            CreateExecutionRequest request = new CreateExecutionRequest
            {
                ParentAsWorkflowName = gcwcv::WorkflowName.FromProjectLocationWorkflow("[PROJECT]", "[LOCATION]", "[WORKFLOW]"),
                Execution            = new Execution(),
            };
            Execution expectedResponse = new Execution
            {
                ExecutionName      = ExecutionName.FromProjectLocationWorkflowExecution("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]"),
                StartTime          = new wkt::Timestamp(),
                EndTime            = new wkt::Timestamp(),
                State              = Execution.Types.State.Failed,
                Argument           = "argument60e0cd03",
                Result             = "result1784a8b4",
                Error              = new Execution.Types.Error(),
                WorkflowRevisionId = "workflow_revision_id3b9c4f02",
            };

            mockGrpcClient.Setup(x => x.CreateExecution(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ExecutionsClient client   = new ExecutionsClientImpl(mockGrpcClient.Object, null);
            Execution        response = client.CreateExecution(request.Parent, request.Execution);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public async stt::Task CreateExecutionRequestObjectAsync()
        {
            moq::Mock <Executions.ExecutionsClient> mockGrpcClient = new moq::Mock <Executions.ExecutionsClient>(moq::MockBehavior.Strict);
            CreateExecutionRequest request = new CreateExecutionRequest
            {
                ParentAsWorkflowName = gcwcv::WorkflowName.FromProjectLocationWorkflow("[PROJECT]", "[LOCATION]", "[WORKFLOW]"),
                Execution            = new Execution(),
            };
            Execution expectedResponse = new Execution
            {
                ExecutionName      = ExecutionName.FromProjectLocationWorkflowExecution("[PROJECT]", "[LOCATION]", "[WORKFLOW]", "[EXECUTION]"),
                StartTime          = new wkt::Timestamp(),
                EndTime            = new wkt::Timestamp(),
                State              = Execution.Types.State.Failed,
                Argument           = "argument60e0cd03",
                Result             = "result1784a8b4",
                Error              = new Execution.Types.Error(),
                WorkflowRevisionId = "workflow_revision_id3b9c4f02",
            };

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

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

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