public async stt::Task CancelJobAsync()
        {
            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);
            CancelJobRequest request = new CancelJobRequest
            {
                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.CancelJobAsync(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.CancelJobAsync(request.ProjectId, request.Region, request.JobId, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemple #2
0
        public async Task CancelJobAsync()
        {
            Mock <JobController.JobControllerClient> mockGrpcClient = new Mock <JobController.JobControllerClient>(MockBehavior.Strict);
            CancelJobRequest expectedRequest = new CancelJobRequest
            {
                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.CancelJobAsync(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.CancelJobAsync(projectId, region, jobId);

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