Beispiel #1
0
        public async stt::Task GetDeploymentRequestObjectAsync()
        {
            moq::Mock <Deployments.DeploymentsClient> mockGrpcClient = new moq::Mock <Deployments.DeploymentsClient>(moq::MockBehavior.Strict);
            GetDeploymentRequest request = new GetDeploymentRequest
            {
                DeploymentName = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"),
            };
            Deployment expectedResponse = new Deployment
            {
                DeploymentName           = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"),
                FlowVersionAsVersionName = VersionName.FromProjectLocationAgentFlowVersion("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[VERSION]"),
                State     = Deployment.Types.State.Succeeded,
                Result    = new Deployment.Types.Result(),
                StartTime = new wkt::Timestamp(),
                EndTime   = new wkt::Timestamp(),
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public void GetDeployment()
        {
            moq::Mock <Deployments.DeploymentsClient> mockGrpcClient = new moq::Mock <Deployments.DeploymentsClient>(moq::MockBehavior.Strict);
            GetDeploymentRequest request = new GetDeploymentRequest
            {
                DeploymentName = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"),
            };
            Deployment expectedResponse = new Deployment
            {
                DeploymentName           = DeploymentName.FromProjectLocationAgentEnvironmentDeployment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]", "[DEPLOYMENT]"),
                FlowVersionAsVersionName = VersionName.FromProjectLocationAgentFlowVersion("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]", "[VERSION]"),
                State     = Deployment.Types.State.Succeeded,
                Result    = new Deployment.Types.Result(),
                StartTime = new wkt::Timestamp(),
                EndTime   = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.GetDeployment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            DeploymentsClient client   = new DeploymentsClientImpl(mockGrpcClient.Object, null);
            Deployment        response = client.GetDeployment(request.Name);

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