public async stt::Task GetJobAsync()
        {
            moq::Mock <JobController.JobControllerClient> mockGrpcClient = new moq::Mock <JobController.JobControllerClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetJobRequest request = new GetJobRequest
            {
                ProjectId = "project_id43ad98b0",
                JobId     = "job_id38ea97d6",
                Region    = "regionedb20d96",
            };
            Job expectedResponse = new Job
            {
                Reference        = new JobReference(),
                Placement        = new JobPlacement(),
                HadoopJob        = new HadoopJob(),
                SparkJob         = new SparkJob(),
                PysparkJob       = new PySparkJob(),
                HiveJob          = new HiveJob(),
                PigJob           = new PigJob(),
                Status           = new JobStatus(),
                YarnApplications =
                {
                    new YarnApplication(),
                },
                SparkSqlJob             = new SparkSqlJob(),
                StatusHistory           = { new JobStatus(), },
                DriverControlFilesUri   = "driver_control_files_uribe41e88b",
                DriverOutputResourceUri = "driver_output_resource_urie2b470d7",
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Scheduling = new JobScheduling(),
                SparkRJob  = new SparkRJob(),
                JobUuid    = "job_uuid7530ffdd",
                PrestoJob  = new PrestoJob(),
                Done       = true,
            };

            mockGrpcClient.Setup(x => x.GetJobAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Job>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            JobControllerClient client = new JobControllerClientImpl(mockGrpcClient.Object, null);
            Job responseCallSettings   = await client.GetJobAsync(request.ProjectId, request.Region, request.JobId, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Job responseCancellationToken = await client.GetJobAsync(request.ProjectId, request.Region, request.JobId, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public async Task GetJobAsync()
        {
            Mock <JobController.JobControllerClient> mockGrpcClient = new Mock <JobController.JobControllerClient>(MockBehavior.Strict);
            GetJobRequest expectedRequest = new GetJobRequest
            {
                ProjectId = "projectId-1969970175",
                Region    = "region-934795532",
                JobId     = "jobId-1154752291",
            };
            Job expectedResponse = new Job
            {
                DriverOutputResourceUri = "driverOutputResourceUri-542229086",
                DriverControlFilesUri   = "driverControlFilesUri207057643",
                JobUuid = "jobUuid-1615012099",
            };

            mockGrpcClient.Setup(x => x.GetJobAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Job>(Task.FromResult(expectedResponse), null, null, null, null));
            JobControllerClient client = new JobControllerClientImpl(mockGrpcClient.Object, null);
            string projectId           = "projectId-1969970175";
            string region   = "region-934795532";
            string jobId    = "jobId-1154752291";
            Job    response = await client.GetJobAsync(projectId, region, jobId);

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