public void DeletePredictionApiKeyRegistrationResourceNames() { moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient> mockGrpcClient = new moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient>(moq::MockBehavior.Strict); DeletePredictionApiKeyRegistrationRequest request = new DeletePredictionApiKeyRegistrationRequest { PredictionApiKeyRegistrationName = PredictionApiKeyRegistrationName.FromProjectLocationCatalogEventStorePredictionApiKeyRegistration("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]", "[PREDICTION_API_KEY_REGISTRATION]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeletePredictionApiKeyRegistration(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PredictionApiKeyRegistryClient client = new PredictionApiKeyRegistryClientImpl(mockGrpcClient.Object, null); client.DeletePredictionApiKeyRegistration(request.PredictionApiKeyRegistrationName); mockGrpcClient.VerifyAll(); }
public async stt::Task DeletePredictionApiKeyRegistrationResourceNamesAsync() { moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient> mockGrpcClient = new moq::Mock <PredictionApiKeyRegistry.PredictionApiKeyRegistryClient>(moq::MockBehavior.Strict); DeletePredictionApiKeyRegistrationRequest request = new DeletePredictionApiKeyRegistrationRequest { PredictionApiKeyRegistrationName = PredictionApiKeyRegistrationName.FromProjectLocationCatalogEventStorePredictionApiKeyRegistration("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]", "[PREDICTION_API_KEY_REGISTRATION]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeletePredictionApiKeyRegistrationAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); PredictionApiKeyRegistryClient client = new PredictionApiKeyRegistryClientImpl(mockGrpcClient.Object, null); await client.DeletePredictionApiKeyRegistrationAsync(request.PredictionApiKeyRegistrationName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeletePredictionApiKeyRegistrationAsync(request.PredictionApiKeyRegistrationName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
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(); }