Exemplo n.º 1
0
        public void CreateWorkflowTemplate2()
        {
            Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(MockBehavior.Strict);

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

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

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public async Task CreateWorkflowTemplateAsync()
        {
            Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(MockBehavior.Strict);

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

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

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        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();
        }
Exemplo n.º 5
0
        public async Task DeleteWorkflowTemplateAsync2()
        {
            Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(MockBehavior.Strict);

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

            mockGrpcClient.Setup(x => x.DeleteWorkflowTemplateAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null));
            WorkflowTemplateServiceClient client = new WorkflowTemplateServiceClientImpl(mockGrpcClient.Object, null);
            await client.DeleteWorkflowTemplateAsync(request);

            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 6
0
        public void DeleteWorkflowTemplate2()
        {
            Mock <WorkflowTemplateService.WorkflowTemplateServiceClient> mockGrpcClient = new Mock <WorkflowTemplateService.WorkflowTemplateServiceClient>(MockBehavior.Strict);

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

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

            client.DeleteWorkflowTemplate(request);
            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();
        }
        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();
        }