Ejemplo n.º 1
0
        public void TestDeletePersonWithPreconditions()
        {
            // Assume the ability to add a person is working
            var state = tree.AddPerson(TestBacking.GetCreateMalePerson());
            cleanup.Add(state);
            state = (PersonState)state.Get();
            var cond = new Preconditions(state.LastModified);

            // Touch the record since the above date
            state.Update(state.Person);

            // This should fail
            var state2 = (PersonState)state.Delete(cond);
            Assert.Throws<GedcomxApplicationException>(() => state2.IfSuccessful());
            Assert.AreEqual(HttpStatusCode.PreconditionFailed, state2.Response.StatusCode);
        }
Ejemplo n.º 2
0
        public void TestUpdatePersonWithPreconditions()
        {
            var state = (FamilyTreePersonState)tree.AddPerson(TestBacking.GetCreateMalePerson()).Get();
            cleanup.Add(state);
            var cond = new Preconditions(state);
            var state2 = state.UpdateFacts(state.Person.Facts.ToArray(), cond);
            Assert.DoesNotThrow(() => state2.IfSuccessful());
            Assert.AreEqual(HttpStatusCode.NoContent, state2.Response.StatusCode);

            state = tree.ReadPersonById(state.Person.Id);
            var state3 = state.UpdateFacts(state.Person.Facts.ToArray(), cond);
            Assert.Throws<GedcomxApplicationException>(() => state3.IfSuccessful());
            Assert.AreEqual(HttpStatusCode.PreconditionFailed, state3.Response.StatusCode);
        }