Example #1
0
        public void CreateDocumentRequestObject()
        {
            moq::Mock <Firestore.FirestoreClient> mockGrpcClient = new moq::Mock <Firestore.FirestoreClient>(moq::MockBehavior.Strict);
            CreateDocumentRequest request = new CreateDocumentRequest
            {
                Parent       = "projects/test/databases/test/documents/parent7858e4d0",
                CollectionId = "collection_idd84d1a0a",
                DocumentId   = "document_id10fcfae7",
                Document     = new Document(),
                Mask         = new DocumentMask(),
            };
            Document expectedResponse = new Document
            {
                Name   = "name1c9368b0",
                Fields =
                {
                    {
                        "key8a0b6e3c",
                        new Value()
                    },
                },
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
            };

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

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void CreateDocument()
        {
            Mock <Firestore.FirestoreClient> mockGrpcClient = new Mock <Firestore.FirestoreClient>(MockBehavior.Strict);
            CreateDocumentRequest            request        = new CreateDocumentRequest
            {
                Parent       = new AnyPathName("[PROJECT]", "[DATABASE]", "[DOCUMENT]", "[ANY_PATH]").ToString(),
                CollectionId = "collectionId-821242276",
                DocumentId   = "documentId506676927",
                Document     = new Document(),
            };
            Document expectedResponse = new Document
            {
                Name = "name3373707",
            };

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

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