Esempio n. 1
0
 /// <summary>Snippet for CreatePredictionApiKeyRegistration</summary>
 public void CreatePredictionApiKeyRegistrationRequestObject()
 {
     // Snippet: CreatePredictionApiKeyRegistration(CreatePredictionApiKeyRegistrationRequest, CallSettings)
     // Create client
     PredictionApiKeyRegistryClient predictionApiKeyRegistryClient = PredictionApiKeyRegistryClient.Create();
     // Initialize request argument(s)
     CreatePredictionApiKeyRegistrationRequest request = new CreatePredictionApiKeyRegistrationRequest
     {
         ParentAsEventStoreName       = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
         PredictionApiKeyRegistration = new PredictionApiKeyRegistration(),
     };
     // Make the request
     PredictionApiKeyRegistration response = predictionApiKeyRegistryClient.CreatePredictionApiKeyRegistration(request);
     // End snippet
 }
        public void CreatePredictionApiKeyRegistration()
        {
            moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient> mockGrpcClient = new moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient>(moq::MockBehavior.Strict);
            CreatePredictionApiKeyRegistrationRequest request = new CreatePredictionApiKeyRegistrationRequest
            {
                ParentAsEventStoreName       = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
                PredictionApiKeyRegistration = new PredictionApiKeyRegistration(),
            };
            PredictionApiKeyRegistration expectedResponse = new PredictionApiKeyRegistration
            {
                ApiKey = "api_key30288039",
            };

            mockGrpcClient.Setup(x => x.CreatePredictionApiKeyRegistration(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            PredictionApiKeyRegistryClient client   = new PredictionApiKeyRegistryClientImpl(mockGrpcClient.Object, null);
            PredictionApiKeyRegistration   response = client.CreatePredictionApiKeyRegistration(request.Parent, request.PredictionApiKeyRegistration);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task CreatePredictionApiKeyRegistrationAsync()
        {
            moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient> mockGrpcClient = new moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient>(moq::MockBehavior.Strict);
            CreatePredictionApiKeyRegistrationRequest request = new CreatePredictionApiKeyRegistrationRequest
            {
                ParentAsEventStoreName       = EventStoreName.FromProjectLocationCatalogEventStore("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]"),
                PredictionApiKeyRegistration = new PredictionApiKeyRegistration(),
            };
            PredictionApiKeyRegistration expectedResponse = new PredictionApiKeyRegistration
            {
                ApiKey = "api_key30288039",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            PredictionApiKeyRegistration responseCancellationToken = await client.CreatePredictionApiKeyRegistrationAsync(request.Parent, request.PredictionApiKeyRegistration, st::CancellationToken.None);

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