public void TestRedirectToPerson() { var person = tree.AddPerson(TestBacking.GetCreateMalePerson()); cleanup.Add(person); var id = person.Response.Headers.Get("X-ENTITY-ID").Single().Value.ToString(); IRestRequest request = new RedirectableRestRequest() .Accept(MediaTypes.APPLICATION_JSON_TYPE) .Build("https://sandbox.familysearch.org/platform/redirect?person=" + id, Method.GET); var response = tree.Client.Execute(request); Assert.IsNotNull(response); Assert.AreEqual(HttpStatusCode.TemporaryRedirect, response.StatusCode); }
public void TestReadPersonWithMultiplePendingModificationsActivated() { // Make a separate copy from the main tree used in other tests var tempTree = new FamilySearchFamilyTree(true); var features = new List <Feature>(); tempTree.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId); // Get all the features that are pending IRestRequest request = new RedirectableRestRequest() .Accept(MediaTypes.APPLICATION_JSON_TYPE) .Build("https://sandbox.familysearch.org/platform/pending-modifications", Method.GET); IRestResponse response = tempTree.Client.Handle(request); // Get each pending feature features.AddRange(response.ToIRestResponse <FamilySearchPlatform>().Data.Features); // Add every pending feature to the tree's current client tempTree.Client.AddFilter(new ExperimentsFilter(features.Select(x => x.Name).ToArray())); var state = tempTree.AddPerson(TestBacking.GetCreateMalePerson()); cleanup.Add(state); // Ensure a response came back Assert.IsNotNull(state); var requestedFeatures = String.Join(",", state.Request.GetHeaders().Get("X-FS-Feature-Tag").Select(x => x.Value.ToString())); // Ensure each requested feature was found in the request headers Assert.IsTrue(features.TrueForAll(x => requestedFeatures.Contains(x.Name))); }
public void TestCreatePersonMemoryReference() { var converter = new ImageConverter(); var bytes = (Byte[])converter.ConvertTo(TestBacking.GetCreatePhoto(), typeof(Byte[])); var dataSource = new BasicDataSource(Guid.NewGuid().ToString("n") + ".jpg", "image/jpeg", bytes); var description = new SourceDescription().SetTitle("PersonImage").SetCitation("Citation for PersonImage").SetDescription("Description"); var image = (SourceDescriptionState)tree.AddArtifact(description, dataSource).Get(); cleanup.Add(image); var person = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(person); var persona = (PersonState)image.AddPersona(new Person().SetName("John Smith")).Get(); var state = person.AddPersonaReference(persona); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.Created, state.Response.StatusCode); }
public void TestCreateUserUploadedSource() { var person = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(person); var dataSource = new BasicDataSource("Sample Memory", MediaTypes.TEXT_PLAIN_TYPE, Resources.MemoryTXT); var sds = person.AddArtifact(dataSource); cleanup.Add(sds); var artifact = person.ReadArtifacts().SourceDescriptions.First(); var memoryUri = artifact.GetLink("memory").Href; var state = tree.AddSourceDescription(TestBacking.GetCreateUserSourceDescription(memoryUri)); cleanup.Add(state); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.Created, state.Response.StatusCode); }
public void TestReadUser() { var person = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(person); var state = person.ReadContributor(person.GetName()); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode); }
public void TestReadPersonPossibleDuplicates() { var person = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(person); var state = person.ReadMatches(); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode); Assert.Greater(state.Results.Entries.Count, 0); }
public void TestReadCoupleRelationshipChangeHistory() { var husband = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(husband); var wife = tree.AddPerson(TestBacking.GetCreateFemalePerson()); cleanup.Add(wife); var relationship = (FamilyTreeRelationshipState)husband.AddSpouse(wife).Get(); cleanup.Add(relationship); relationship.AddFact(TestBacking.GetMarriageFact()); cleanup.Add(relationship); var state = relationship.ReadChangeHistory(); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode); Assert.IsNotNull(state.Page); Assert.IsNotNull(state.Page.Entries); Assert.Greater(state.Page.Entries.Count, 0); }
public void TestReadNote() { var person = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(person); person.AddNote(new Note().SetText("This is a note.").SetSubject("This is a note.")); var notes = person.LoadNotes(); var state = notes.ReadNote(notes.Entity.Persons[0].Notes[0]); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode); Assert.IsNotNull(state.Person); Assert.IsNotNull(state.Person.Notes); Assert.Greater(state.Person.Notes.Count, 0); }
public void TestCreatePerson() { var result = tree.AddPerson(TestBacking.GetCreateMalePerson()); cleanup.Add(result); Assert.DoesNotThrow(() => result.IfSuccessful()); var person = (PersonState)result.Get(); Assert.IsNotNull(person.Person); Assert.IsNotNullOrEmpty(person.Person.Id); }
public void TestCreateChildAndParentsRelationship() { var father = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(father); var mother = tree.AddPerson(TestBacking.GetCreateFemalePerson()); cleanup.Add(mother); var son = tree.AddPerson(TestBacking.GetCreateMalePerson()); cleanup.Add(son); var state = tree.AddChildAndParentsRelationship(TestBacking.GetCreateChildAndParentsRelationship(father, mother, son)); cleanup.Add(state); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.Created, state.Response.StatusCode); }
public void TestReadPersonAncestry() { var grandfather = tree.AddPerson(TestBacking.GetCreateMalePerson()); cleanup.Add(grandfather); var father = tree.AddPerson(TestBacking.GetCreateMalePerson()); cleanup.Add(father); var son = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(son); var rel1 = tree.AddChildAndParentsRelationship(TestBacking.GetCreateChildAndParentsRelationship(grandfather, null, father)); cleanup.Add(rel1); var rel2 = tree.AddChildAndParentsRelationship(TestBacking.GetCreateChildAndParentsRelationship(father, null, son)); cleanup.Add(rel2); son = tree.ReadPersonById(son.Person.Id); var state = son.ReadAncestry(); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode); Assert.IsNotNull(state.Tree); Assert.IsNotNull(state.Tree.Root); Assert.IsNotNull(state.Tree.Root.Person); Assert.IsNotNull(state.Tree.Root.Father); Assert.IsNotNull(state.Tree.Root.Father.Person); Assert.IsNotNull(state.Tree.Root.Father.Father); Assert.IsNotNull(state.Tree.Root.Father.Father.Person); Assert.AreEqual(grandfather.GetSelfUri(), state.Tree.Root.Father.Father.Person.GetLink("self").Href); Assert.AreEqual(father.GetSelfUri(), state.Tree.Root.Father.Person.GetLink("self").Href); Assert.AreEqual(son.GetSelfUri(), state.Tree.Root.Person.GetLink("self").Href); }
public void TestCreateCoupleRelationship() { var husband = (PersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(husband); var wife = tree.AddPerson(TestBacking.GetCreateFemalePerson()); cleanup.Add(wife); var state = husband.AddSpouse(wife); cleanup.Add(state); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.Created, state.Response.StatusCode); }