示例#1
0
 /// <summary>
 /// Verify that each node in the hierarchy has the expected children
 /// and all Parent back pointers are valid.
 /// </summary>
 private static void VerifyHierarchy(CI_Parent parent)
 {
     Assert.IsTrue(parent.Children.Count > 0);
     foreach (CI_Child c in parent.Children)
     {
         Assert.AreSame(parent, c.Parent);
     }
 }
示例#2
0
        public void Composition_Inheritance_Update_Base_Child_On_Base_Parent()
        {
            CompositionInheritanceScenarios ctxt = new CompositionInheritanceScenarios(CompositionInheritanceScenarios_Uri);

            CI_Parent            parent          = null;
            SubmitOperation      so              = null;
            IEnumerable <Entity> expectedUpdates = null;
            LoadOperation        lo              = ctxt.Load(ctxt.GetParentsQuery(), false);

            EnqueueConditional(() => lo.IsComplete);
            EnqueueCallback(delegate
            {
                TestHelperMethods.AssertOperationSuccess(lo);

                parent = ctxt.CI_Parents.First(p => p.GetType() == typeof(CI_Parent));
                CI_Child existingChild = parent.Children.First(c => c.GetType() == typeof(CI_Child));
                Assert.AreSame(parent, ((Entity)existingChild).Parent);

                // update derived comp child
                existingChild.Age++;;

                EntityChangeSet cs = ctxt.EntityContainer.GetChanges();
                Assert.IsTrue(cs.ModifiedEntities.Count == 2, "wrong modified count");
                Assert.IsTrue(cs.RemovedEntities.Count == 0, "wrong removed count");
                Assert.IsTrue(cs.ModifiedEntities.Contains(parent));
                Assert.IsTrue(cs.ModifiedEntities.Contains(existingChild));

                // verify that original associations are set up correctly
                IEnumerable <ChangeSetEntry> entityOps = ChangeSetBuilder.Build(cs);
                this.ValidateEntityOperationAssociations(entityOps);

                expectedUpdates = cs.Where(p => p.HasChildChanges || p.HasPropertyChanges).ToArray();
                so = ctxt.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            });
            EnqueueConditional(() => so.IsComplete);
            EnqueueCallback(delegate
            {
                this.VerifySuccess(ctxt, so, expectedUpdates);
            });

            EnqueueTestComplete();
        }