Example #1
0
        public void BeginTransactionRequestObject()
        {
            moq::Mock <Firestore.FirestoreClient> mockGrpcClient = new moq::Mock <Firestore.FirestoreClient>(moq::MockBehavior.Strict);
            BeginTransactionRequest request = new BeginTransactionRequest
            {
                Database = "projects/test/databases/databased8eee011",
                Options  = new TransactionOptions(),
            };
            BeginTransactionResponse expectedResponse = new BeginTransactionResponse
            {
                Transaction = proto::ByteString.CopyFromUtf8("transaction6ab7d5f4"),
            };

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

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void BeginTransaction2()
        {
            Mock <Firestore.FirestoreClient> mockGrpcClient = new Mock <Firestore.FirestoreClient>(MockBehavior.Strict);
            BeginTransactionRequest          request        = new BeginTransactionRequest
            {
                Database = new DatabaseRootName("[PROJECT]", "[DATABASE]").ToString(),
            };
            BeginTransactionResponse expectedResponse = new BeginTransactionResponse
            {
                Transaction = ByteString.CopyFromUtf8("-34"),
            };

            mockGrpcClient.Setup(x => x.BeginTransaction(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            FirestoreClient          client   = new FirestoreClientImpl(mockGrpcClient.Object, null);
            BeginTransactionResponse response = client.BeginTransaction(request);

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