Exemplo n.º 1
0
        public void TestReadPreferredParentRelationship()
        {
            var father = tree.AddPerson(TestBacking.GetCreateMalePerson());

            cleanup.Add(father);
            var son = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get();

            cleanup.Add(son);
            var chapr = tree.AddChildAndParentsRelationship(TestBacking.GetCreateChildAndParentsRelationship(father, null, son));

            cleanup.Add(chapr);
            var me = tree.ReadCurrentUser();

            // Ensure the target relationship exists
            var relationship = ((FamilyTreePersonParentsState)son.ReadParents()).ChildAndParentsRelationships.First();
            var state        = son.ReadChildAndParentsRelationship(relationship);

            tree.UpdatePreferredParentRelationship(me.User.TreeUserId, son.Person.Id, state);

            var state2 = (FamilyTreeRelationshipState)tree.ReadPreferredParentRelationship(me.User.TreeUserId, son.Person.Id);

            Assert.AreEqual(HttpStatusCode.SeeOther, state2.Response.StatusCode);
            Assert.IsNotNull(state2.Headers.Get("Location").Single());
        }