public async stt::Task CreateTrainingPipelineRequestObjectAsync() { moq::Mock <PipelineService.PipelineServiceClient> mockGrpcClient = new moq::Mock <PipelineService.PipelineServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); CreateTrainingPipelineRequest request = new CreateTrainingPipelineRequest { ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), TrainingPipeline = new TrainingPipeline(), }; TrainingPipeline expectedResponse = new TrainingPipeline { TrainingPipelineName = TrainingPipelineName.FromProjectLocationTrainingPipeline("[PROJECT]", "[LOCATION]", "[TRAINING_PIPELINE]"), DisplayName = "display_name137f65c2", InputDataConfig = new InputDataConfig(), TrainingTaskDefinition = "training_task_definition3e3456be", TrainingTaskInputs = new wkt::Value(), TrainingTaskMetadata = new wkt::Value(), ModelToUpload = new Model(), State = PipelineState.Running, Error = new gr::Status(), CreateTime = new wkt::Timestamp(), StartTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, EncryptionSpec = new EncryptionSpec(), }; mockGrpcClient.Setup(x => x.CreateTrainingPipelineAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <TrainingPipeline>(stt::Task.FromResult(expectedResponse), null, null, null, null)); PipelineServiceClient client = new PipelineServiceClientImpl(mockGrpcClient.Object, null); TrainingPipeline responseCallSettings = await client.CreateTrainingPipelineAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); TrainingPipeline responseCancellationToken = await client.CreateTrainingPipelineAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void CancelTrainingPipelineResourceNames() { moq::Mock <PipelineService.PipelineServiceClient> mockGrpcClient = new moq::Mock <PipelineService.PipelineServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); CancelTrainingPipelineRequest request = new CancelTrainingPipelineRequest { TrainingPipelineName = TrainingPipelineName.FromProjectLocationTrainingPipeline("[PROJECT]", "[LOCATION]", "[TRAINING_PIPELINE]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.CancelTrainingPipeline(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PipelineServiceClient client = new PipelineServiceClientImpl(mockGrpcClient.Object, null); client.CancelTrainingPipeline(request.TrainingPipelineName); mockGrpcClient.VerifyAll(); }
public async stt::Task CancelTrainingPipelineResourceNamesAsync() { moq::Mock <PipelineService.PipelineServiceClient> mockGrpcClient = new moq::Mock <PipelineService.PipelineServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); CancelTrainingPipelineRequest request = new CancelTrainingPipelineRequest { TrainingPipelineName = TrainingPipelineName.FromProjectLocationTrainingPipeline("[PROJECT]", "[LOCATION]", "[TRAINING_PIPELINE]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.CancelTrainingPipelineAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); PipelineServiceClient client = new PipelineServiceClientImpl(mockGrpcClient.Object, null); await client.CancelTrainingPipelineAsync(request.TrainingPipelineName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.CancelTrainingPipelineAsync(request.TrainingPipelineName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
public void GetTrainingPipelineResourceNames() { moq::Mock <PipelineService.PipelineServiceClient> mockGrpcClient = new moq::Mock <PipelineService.PipelineServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetTrainingPipelineRequest request = new GetTrainingPipelineRequest { TrainingPipelineName = TrainingPipelineName.FromProjectLocationTrainingPipeline("[PROJECT]", "[LOCATION]", "[TRAINING_PIPELINE]"), }; TrainingPipeline expectedResponse = new TrainingPipeline { TrainingPipelineName = TrainingPipelineName.FromProjectLocationTrainingPipeline("[PROJECT]", "[LOCATION]", "[TRAINING_PIPELINE]"), DisplayName = "display_name137f65c2", InputDataConfig = new InputDataConfig(), TrainingTaskDefinition = "training_task_definition3e3456be", TrainingTaskInputs = new wkt::Value(), TrainingTaskMetadata = new wkt::Value(), ModelToUpload = new Model(), State = PipelineState.Running, Error = new gr::Status(), CreateTime = new wkt::Timestamp(), StartTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, EncryptionSpec = new EncryptionSpec(), }; mockGrpcClient.Setup(x => x.GetTrainingPipeline(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PipelineServiceClient client = new PipelineServiceClientImpl(mockGrpcClient.Object, null); TrainingPipeline response = client.GetTrainingPipeline(request.TrainingPipelineName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }