コード例 #1
0
        public void MultipleDocumentsCanBeRetrieved()
        {
            const int     personCount = 3;
            List <Person> people      = CreateMultiplePersons(personCount);

            var createResponses = new Dictionary <Guid, Person>();

            people.ForEach(person =>
            {
                DocumentSaveSuccessResponse createResponse = AssertCreatePersonSuccess(person, testVaultId);
                documentSuccessResponses.Push(createResponse);
                createResponses.Add(createResponse.DocumentId, person);
            });

            MultiDocumentResponse multipleRetrievedDocuments = trueVaultClient.MultiGetDocuments(testVaultId,
                                                                                                 createResponses.Select(c => c.Key).ToArray());

            Assert.AreEqual(personCount, multipleRetrievedDocuments.Documents.Count());

            IEnumerable <DocumentResponse> retrievedPeopleDocs = multipleRetrievedDocuments.Documents;

            foreach (DocumentResponse doc in retrievedPeopleDocs)
            {
                var deserializedPerson = doc.DeserializeDocument <Person>();
                Assert.IsTrue(createResponses.ContainsKey(doc.Id));
                Assert.AreEqual(createResponses[doc.Id].Id, deserializedPerson.Id);
                Assert.AreEqual(createResponses[doc.Id].Name, deserializedPerson.Name);
                Assert.AreEqual(createResponses[doc.Id].Email, deserializedPerson.Email);
            }
        }
コード例 #2
0
        private DocumentSaveSuccessResponse AssertCreatePersonSuccess(Person person, Guid vaultId)
        {
            DocumentSaveSuccessResponse response = trueVaultClient.CreateDocument(vaultId, person);

            Assert.IsNotNull(response, "Response should not be null");
            Assert.AreNotEqual(response.DocumentId, default(Guid), "Document ID should be a non-default GUID");
            Assert.AreNotEqual(response.TransactionId, default(Guid), "Transaction ID should be a non-default GUID");
            Assert.AreEqual(response.Result, "success", "Response should indicate success");

            return(response);
        }
コード例 #3
0
        public void ExistingDocumentCanBeRetrieved()
        {
            Person person = CreatePerson();
            DocumentSaveSuccessResponse createResponse = AssertCreatePersonSuccess(person, testVaultId);

            documentSuccessResponses.Push(createResponse);

            var retrievedPerson = trueVaultClient.GetDocument <Person>(testVaultId, createResponse.DocumentId);

            Assert.AreEqual(person.Id, retrievedPerson.Id);
            Assert.AreEqual(person.Name, retrievedPerson.Name);
            Assert.AreEqual(person.Email, retrievedPerson.Email);
        }
コード例 #4
0
        public void ExistingDocumentCanBeEdited()
        {
            Person person = CreatePerson();
            DocumentSaveSuccessResponse createResponse = AssertCreatePersonSuccess(person, testVaultId);

            documentSuccessResponses.Push(createResponse);

            person.Name += " Justgotmarried";
            person.Email = string.Format("{0}@truevaulttest.net", Guid.NewGuid());

            TrueVaultResponse editResponse = trueVaultClient.UpdateDocument(testVaultId, createResponse.DocumentId,
                                                                            person);

            Assert.AreEqual(editResponse.Result, "success", "Edit response should indicate success");
            Assert.AreNotEqual(editResponse.TransactionId, default(Guid),
                               "Edit response Transaction ID should be a non-default GUID");

            var retrievedPerson = trueVaultClient.GetDocument <Person>(testVaultId, createResponse.DocumentId);

            Assert.AreEqual(person.Id, retrievedPerson.Id);
            Assert.AreEqual(person.Name, retrievedPerson.Name);
            Assert.AreEqual(person.Email, retrievedPerson.Email);
        }