public void TestMergePerson()
        {
            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));
            var state = merge.DoMerge(m);

            Assert.DoesNotThrow(() => state.IfSuccessful());
            Assert.AreEqual(HttpStatusCode.NoContent, state.Response.StatusCode);
            Assert.AreEqual(person1.Get().GetSelfUri(), person2.Get().GetSelfUri());
        }
 public void VisitMerge(Merge merge)
 {
     //no-op.
 }
        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);
        }
 /**
  * Add a merge to the data set.
  *
  * @param merge The merge to be added.
  */
 public void AddMerge(Merge merge)
 {
     if (merge != null)
     {
         if (_merges == null)
             _merges = new List<Merge>();
         _merges.Add(merge);
     }
 }