public async stt::Task SubmitJobRequestObjectAsync() { 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); SubmitJobRequest request = new SubmitJobRequest { ProjectId = "project_id43ad98b0", Job = new Job(), Region = "regionedb20d96", RequestId = "request_id362c8df6", }; 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.SubmitJobAsync(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.SubmitJobAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Job responseCancellationToken = await client.SubmitJobAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task SubmitJobAsync() { Mock <JobController.JobControllerClient> mockGrpcClient = new Mock <JobController.JobControllerClient>(MockBehavior.Strict); SubmitJobRequest expectedRequest = new SubmitJobRequest { ProjectId = "projectId-1969970175", Region = "region-934795532", Job = new Job(), }; Job expectedResponse = new Job { DriverOutputResourceUri = "driverOutputResourceUri-542229086", DriverControlFilesUri = "driverControlFilesUri207057643", JobUuid = "jobUuid-1615012099", }; mockGrpcClient.Setup(x => x.SubmitJobAsync(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"; Job job = new Job(); Job response = await client.SubmitJobAsync(projectId, region, job); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }