예제 #1
0
        public void BeginTransaction()
        {
            moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict);
            BeginTransactionRequest request = new BeginTransactionRequest
            {
                ProjectId = "project_id43ad98b0",
            };
            BeginTransactionResponse expectedResponse = new BeginTransactionResponse
            {
                Transaction = proto::ByteString.CopyFromUtf8("transaction6ab7d5f4"),
            };

            mockGrpcClient.Setup(x => x.BeginTransaction(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            DatastoreClient          client   = new DatastoreClientImpl(mockGrpcClient.Object, null);
            BeginTransactionResponse response = client.BeginTransaction(request.ProjectId);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void BeginTransaction2()
        {
            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.BeginTransaction(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            DatastoreClient          client   = new DatastoreClientImpl(mockGrpcClient.Object, null);
            BeginTransactionResponse response = client.BeginTransaction(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }