public void AllocateIds() { // Snippet: AllocateIds(string,IEnumerable<Key>,CallSettings) // Create client DatastoreClient datastoreClient = DatastoreClient.Create(); // Initialize request argument(s) string projectId = ""; IEnumerable <Key> keys = new List <Key>(); // Make the request AllocateIdsResponse response = datastoreClient.AllocateIds(projectId, keys); // End snippet }
public async Task AllocateIdsAsync() { // Snippet: AllocateIdsAsync(string,IEnumerable<Key>,CallSettings) // Additional: AllocateIdsAsync(string,IEnumerable<Key>,CancellationToken) // Create client DatastoreClient datastoreClient = DatastoreClient.Create(); // Initialize request argument(s) string projectId = ""; IEnumerable <Key> keys = new List <Key>(); // Make the request AllocateIdsResponse response = await datastoreClient.AllocateIdsAsync(projectId, keys); // End snippet }
public void AllocateIds_RequestObject() { // Snippet: AllocateIds(AllocateIdsRequest,CallSettings) // Create client DatastoreClient datastoreClient = DatastoreClient.Create(); // Initialize request argument(s) AllocateIdsRequest request = new AllocateIdsRequest { ProjectId = "", Keys = { }, }; // Make the request AllocateIdsResponse response = datastoreClient.AllocateIds(request); // End snippet }
public async Task AllocateIdsAsync_RequestObject() { // Snippet: AllocateIdsAsync(AllocateIdsRequest,CallSettings) // Create client DatastoreClient datastoreClient = await DatastoreClient.CreateAsync(); // Initialize request argument(s) AllocateIdsRequest request = new AllocateIdsRequest { ProjectId = "", Keys = { }, }; // Make the request AllocateIdsResponse response = await datastoreClient.AllocateIdsAsync(request); // End snippet }
public async Task AllocateIdsAsync2() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); AllocateIdsRequest request = new AllocateIdsRequest { ProjectId = "projectId-1969970175", Keys = { }, }; AllocateIdsResponse expectedResponse = new AllocateIdsResponse(); mockGrpcClient.Setup(x => x.AllocateIdsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <AllocateIdsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); AllocateIdsResponse response = await client.AllocateIdsAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void AllocateIds2() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); AllocateIdsRequest request = new AllocateIdsRequest { ProjectId = "projectId-1969970175", Keys = { }, }; AllocateIdsResponse expectedResponse = new AllocateIdsResponse(); mockGrpcClient.Setup(x => x.AllocateIds(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); AllocateIdsResponse response = client.AllocateIds(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for AllocateIdsAsync</summary> public async Task AllocateIdsRequestObjectAsync() { // Snippet: AllocateIdsAsync(AllocateIdsRequest, CallSettings) // Additional: AllocateIdsAsync(AllocateIdsRequest, CancellationToken) // Create client DatastoreClient datastoreClient = await DatastoreClient.CreateAsync(); // Initialize request argument(s) AllocateIdsRequest request = new AllocateIdsRequest { Keys = { new Key(), }, ProjectId = "", }; // Make the request AllocateIdsResponse response = await datastoreClient.AllocateIdsAsync(request); // End snippet }
public void AllocateIds() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); AllocateIdsRequest request = new AllocateIdsRequest { Keys = { new Key(), }, ProjectId = "project_id43ad98b0", }; AllocateIdsResponse expectedResponse = new AllocateIdsResponse { Keys = { new Key(), }, }; mockGrpcClient.Setup(x => x.AllocateIds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); AllocateIdsResponse response = client.AllocateIds(request.ProjectId, request.Keys); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void AllocateIds() { string projectId = _fixture.ProjectId; string namespaceId = _fixture.NamespaceId; // Snippet: AllocateIds(*,*,*) DatastoreClient client = DatastoreClient.Create(); KeyFactory keyFactory = new KeyFactory(projectId, namespaceId, "message"); AllocateIdsResponse response = client.AllocateIds(projectId, new[] { keyFactory.CreateIncompleteKey(), keyFactory.CreateIncompleteKey() } ); Entity entity1 = new Entity { Key = response.Keys[0], ["text"] = "Text 1" }; Entity entity2 = new Entity { Key = response.Keys[1], ["text"] = "Text 2" }; // End snippet Assert.NotEqual(entity1, entity2); }
public async stt::Task AllocateIdsAsync() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); AllocateIdsRequest request = new AllocateIdsRequest { Keys = { new Key(), }, ProjectId = "project_id43ad98b0", }; AllocateIdsResponse expectedResponse = new AllocateIdsResponse { Keys = { new Key(), }, }; mockGrpcClient.Setup(x => x.AllocateIdsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AllocateIdsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); AllocateIdsResponse responseCallSettings = await client.AllocateIdsAsync(request.ProjectId, request.Keys, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); AllocateIdsResponse responseCancellationToken = await client.AllocateIdsAsync(request.ProjectId, request.Keys, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }