public async stt::Task Commit2Async() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); CommitRequest request = new CommitRequest { Mode = CommitRequest.Types.Mode.Unspecified, Mutations = { new Mutation(), }, ProjectId = "project_id43ad98b0", }; CommitResponse expectedResponse = new CommitResponse { MutationResults = { new MutationResult(), }, IndexUpdates = 1466771529, }; mockGrpcClient.Setup(x => x.CommitAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <CommitResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); CommitResponse responseCallSettings = await client.CommitAsync(request.ProjectId, request.Mode, request.Mutations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); CommitResponse responseCancellationToken = await client.CommitAsync(request.ProjectId, request.Mode, request.Mutations, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void Commit2() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); CommitRequest request = new CommitRequest { Mode = CommitRequest.Types.Mode.Unspecified, Mutations = { new Mutation(), }, ProjectId = "project_id43ad98b0", }; CommitResponse expectedResponse = new CommitResponse { MutationResults = { new MutationResult(), }, IndexUpdates = 1466771529, }; mockGrpcClient.Setup(x => x.Commit(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); CommitResponse response = client.Commit(request.ProjectId, request.Mode, request.Mutations); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task CommitAsync2() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); CommitRequest expectedRequest = new CommitRequest { ProjectId = "projectId-1969970175", Mode = CommitRequest.Types.Mode.Unspecified, Mutations = { }, }; CommitResponse expectedResponse = new CommitResponse { IndexUpdates = 1425228195, }; mockGrpcClient.Setup(x => x.CommitAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <CommitResponse>(Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); string projectId = "projectId-1969970175"; CommitRequest.Types.Mode mode = CommitRequest.Types.Mode.Unspecified; IEnumerable <Mutation> mutations = new List <Mutation>(); CommitResponse response = await client.CommitAsync(projectId, mode, mutations); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void Commit() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); CommitRequest expectedRequest = new CommitRequest { ProjectId = "projectId-1969970175", Mode = CommitRequest.Types.Mode.Unspecified, Transaction = ByteString.CopyFromUtf8("-34"), Mutations = { }, }; CommitResponse expectedResponse = new CommitResponse { IndexUpdates = 1425228195, }; mockGrpcClient.Setup(x => x.Commit(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); string projectId = "projectId-1969970175"; CommitRequest.Types.Mode mode = CommitRequest.Types.Mode.Unspecified; ByteString transaction = ByteString.CopyFromUtf8("-34"); IEnumerable <Mutation> mutations = new List <Mutation>(); CommitResponse response = client.Commit(projectId, mode, transaction, mutations); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task LookupRequestObjectAsync() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); LookupRequest request = new LookupRequest { ReadOptions = new ReadOptions(), Keys = { new Key(), }, ProjectId = "project_id43ad98b0", }; LookupResponse expectedResponse = new LookupResponse { Found = { new EntityResult(), }, Missing = { new EntityResult(), }, Deferred = { new Key(), }, }; mockGrpcClient.Setup(x => x.LookupAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <LookupResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); LookupResponse responseCallSettings = await client.LookupAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); LookupResponse responseCancellationToken = await client.LookupAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task RunQueryRequestObjectAsync() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); RunQueryRequest request = new RunQueryRequest { ReadOptions = new ReadOptions(), PartitionId = new PartitionId(), Query = new Query(), GqlQuery = new GqlQuery(), ProjectId = "project_id43ad98b0", }; RunQueryResponse expectedResponse = new RunQueryResponse { Batch = new QueryResultBatch(), Query = new Query(), }; mockGrpcClient.Setup(x => x.RunQueryAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <RunQueryResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); RunQueryResponse responseCallSettings = await client.RunQueryAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); RunQueryResponse responseCancellationToken = await client.RunQueryAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void Rollback2() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); RollbackRequest request = new RollbackRequest { ProjectId = "projectId-1969970175", Transaction = ByteString.CopyFromUtf8("-34"), }; RollbackResponse expectedResponse = new RollbackResponse(); mockGrpcClient.Setup(x => x.Rollback(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); RollbackResponse response = client.Rollback(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void Lookup2() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); LookupRequest request = new LookupRequest { ProjectId = "projectId-1969970175", Keys = { }, }; LookupResponse expectedResponse = new LookupResponse(); mockGrpcClient.Setup(x => x.Lookup(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); LookupResponse response = client.Lookup(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void RunQuery() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); RunQueryRequest request = new RunQueryRequest { ProjectId = "projectId-1969970175", PartitionId = new PartitionId(), }; RunQueryResponse expectedResponse = new RunQueryResponse(); mockGrpcClient.Setup(x => x.RunQuery(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); RunQueryResponse response = client.RunQuery(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void Rollback() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); RollbackRequest request = new RollbackRequest { Transaction = proto::ByteString.CopyFromUtf8("transaction6ab7d5f4"), ProjectId = "project_id43ad98b0", }; RollbackResponse expectedResponse = new RollbackResponse { }; mockGrpcClient.Setup(x => x.Rollback(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); RollbackResponse response = client.Rollback(request.ProjectId, request.Transaction); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void ReserveIds() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); ReserveIdsRequest request = new ReserveIdsRequest { Keys = { new Key(), }, ProjectId = "project_id43ad98b0", }; ReserveIdsResponse expectedResponse = new ReserveIdsResponse { }; mockGrpcClient.Setup(x => x.ReserveIds(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); ReserveIdsResponse response = client.ReserveIds(request.ProjectId, request.Keys); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task ReserveIdsAsync2() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); ReserveIdsRequest request = new ReserveIdsRequest { ProjectId = "projectId-1969970175", Keys = { }, }; ReserveIdsResponse expectedResponse = new ReserveIdsResponse(); mockGrpcClient.Setup(x => x.ReserveIdsAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <ReserveIdsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); ReserveIdsResponse response = await client.ReserveIdsAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task BeginTransactionAsync2() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); BeginTransactionRequest request = new BeginTransactionRequest { ProjectId = "projectId-1969970175", }; BeginTransactionResponse expectedResponse = new BeginTransactionResponse { Transaction = ByteString.CopyFromUtf8("-34"), }; mockGrpcClient.Setup(x => x.BeginTransactionAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <BeginTransactionResponse>(Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); BeginTransactionResponse response = await client.BeginTransactionAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task RollbackAsync() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); RollbackRequest expectedRequest = new RollbackRequest { ProjectId = "projectId-1969970175", Transaction = ByteString.CopyFromUtf8("-34"), }; RollbackResponse expectedResponse = new RollbackResponse(); mockGrpcClient.Setup(x => x.RollbackAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <RollbackResponse>(Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); string projectId = "projectId-1969970175"; ByteString transaction = ByteString.CopyFromUtf8("-34"); RollbackResponse response = await client.RollbackAsync(projectId, transaction); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task AllocateIdsAsync() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); AllocateIdsRequest expectedRequest = new AllocateIdsRequest { ProjectId = "projectId-1969970175", Keys = { }, }; AllocateIdsResponse expectedResponse = new AllocateIdsResponse(); mockGrpcClient.Setup(x => x.AllocateIdsAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <AllocateIdsResponse>(Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); string projectId = "projectId-1969970175"; IEnumerable <Key> keys = new List <Key>(); AllocateIdsResponse response = await client.AllocateIdsAsync(projectId, keys); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void ReserveIds() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); ReserveIdsRequest expectedRequest = new ReserveIdsRequest { ProjectId = "projectId-1969970175", Keys = { }, }; ReserveIdsResponse expectedResponse = new ReserveIdsResponse(); mockGrpcClient.Setup(x => x.ReserveIds(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); string projectId = "projectId-1969970175"; IEnumerable <Key> keys = new List <Key>(); ReserveIdsResponse response = client.ReserveIds(projectId, keys); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task ReserveIdsAsync() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); ReserveIdsRequest request = new ReserveIdsRequest { Keys = { new Key(), }, ProjectId = "project_id43ad98b0", }; ReserveIdsResponse expectedResponse = new ReserveIdsResponse { }; mockGrpcClient.Setup(x => x.ReserveIdsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ReserveIdsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); ReserveIdsResponse responseCallSettings = await client.ReserveIdsAsync(request.ProjectId, request.Keys, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ReserveIdsResponse responseCancellationToken = await client.ReserveIdsAsync(request.ProjectId, request.Keys, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task RollbackAsync() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); RollbackRequest request = new RollbackRequest { Transaction = proto::ByteString.CopyFromUtf8("transaction6ab7d5f4"), ProjectId = "project_id43ad98b0", }; RollbackResponse expectedResponse = new RollbackResponse { }; mockGrpcClient.Setup(x => x.RollbackAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <RollbackResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); RollbackResponse responseCallSettings = await client.RollbackAsync(request.ProjectId, request.Transaction, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); RollbackResponse responseCancellationToken = await client.RollbackAsync(request.ProjectId, request.Transaction, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void BeginTransaction() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); BeginTransactionRequest expectedRequest = new BeginTransactionRequest { ProjectId = "projectId-1969970175", }; BeginTransactionResponse expectedResponse = new BeginTransactionResponse { Transaction = ByteString.CopyFromUtf8("-34"), }; mockGrpcClient.Setup(x => x.BeginTransaction(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); string projectId = "projectId-1969970175"; BeginTransactionResponse response = client.BeginTransaction(projectId); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void Commit3() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); CommitRequest request = new CommitRequest { ProjectId = "projectId-1969970175", Mode = CommitRequest.Types.Mode.Unspecified, Mutations = { }, }; CommitResponse expectedResponse = new CommitResponse { IndexUpdates = 1425228195, }; mockGrpcClient.Setup(x => x.Commit(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); CommitResponse response = client.Commit(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void Lookup() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); LookupRequest request = new LookupRequest { ReadOptions = new ReadOptions(), Keys = { new Key(), }, ProjectId = "project_id43ad98b0", }; LookupResponse expectedResponse = new LookupResponse { Found = { new EntityResult(), }, Missing = { new EntityResult(), }, Deferred = { new Key(), }, }; mockGrpcClient.Setup(x => x.Lookup(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); LookupResponse response = client.Lookup(request.ProjectId, request.ReadOptions, request.Keys); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void RunQueryRequestObject() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); RunQueryRequest request = new RunQueryRequest { ReadOptions = new ReadOptions(), PartitionId = new PartitionId(), Query = new Query(), GqlQuery = new GqlQuery(), ProjectId = "project_id43ad98b0", }; RunQueryResponse expectedResponse = new RunQueryResponse { Batch = new QueryResultBatch(), Query = new Query(), }; mockGrpcClient.Setup(x => x.RunQuery(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); RunQueryResponse response = client.RunQuery(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }