public void TestReadMergedPerson() { var person1 = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(person1); var person2 = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(person2); var merge = person1.ReadMergeAnalysis(person2); var m = new Merge(); m.ResourcesToCopy = new List <ResourceReference>(); m.ResourcesToDelete = new List <ResourceReference>(); m.ResourcesToCopy.AddRange(merge.Analysis.DuplicateResources); m.ResourcesToCopy.AddRange(merge.Analysis.ConflictingResources.Select(x => x.DuplicateResource)); merge.DoMerge(m); // Person2 was merged with Person1 var state = tree.ReadPersonById(person2.Person.Id); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.MovedPermanently, state.Response.StatusCode); var link1 = person1.GetSelfUri(); Assert.IsNotNullOrEmpty(link1); var link2 = state.GetSelfUri(); Assert.IsNotNullOrEmpty(link2); Assert.AreEqual(link1, link2); }
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 TestReadPersonNotAMatchDeclarations() { var person1 = tree.AddPerson(TestBacking.GetCreateMalePerson()); cleanup.Add(person1); var person2 = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get(); cleanup.Add(person2); Thread.Sleep(10000); // This is to ensure the matching system on the server has time to recognize the two new duplicates var matches = person2.ReadMatches(); var entry = matches.Results.Entries.FirstOrDefault(); var id = entry.Id; var match = tree.ReadPersonById(id); person2.AddNonMatch(match); var state = person2.ReadNonMatches(); Assert.DoesNotThrow(() => state.IfSuccessful()); Assert.AreEqual(HttpStatusCode.OK, state.Response.StatusCode); }