public void UpdateSelfReferentialComposition()
        {
            CompositionScenarios_Various ctxt = new CompositionScenarios_Various(CompositionScenarios_Various_Uri);

            LoadOperation lo = ctxt.Load(ctxt.GetSelfReferencingCompositionsQuery(), false);
            SubmitOperation so = null;

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

                SelfReferencingComposition parent = ctxt.SelfReferencingCompositions.First(p => p.Parent == null);
                SelfReferencingComposition child = parent.Child;

                parent.Value += "x";
                child.Value += "x";

                List<ChangeSetEntry> changeSetEntries = ChangeSetBuilder.Build(ctxt.EntityContainer.GetChanges());

                so = ctxt.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            });
            EnqueueConditional(() => so.IsComplete);
            EnqueueCallback(delegate
            {
                TestHelperMethods.AssertOperationSuccess(so);
            });

            EnqueueTestComplete();
        }
        public void UpdateChildWithParentUnloaded()
        {
            CompositionScenarios_Various ctxt = new CompositionScenarios_Various(CompositionScenarios_Various_Uri);

            LoadOperation lo = ctxt.Load(ctxt.GetChildrenQuery(1), false);
            SubmitOperation so = null;

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

                CompositionScenarios_Child child = lo.Entities.Cast<CompositionScenarios_Child>().Single();
                Assert.IsNull(child.Parent);

                child.A += "x";

                so = ctxt.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            });
            EnqueueConditional(() => so.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.IsTrue(so.HasError);
            });

            EnqueueTestComplete();
        }
        public void CompositionSelfReference_UpdateParentWithNoChildren()
        {
            CompositionScenarios_Various ctxt = new CompositionScenarios_Various(CompositionScenarios_Various_Uri);

            LoadOperation lo = ctxt.Load(ctxt.GetSelfReferencingCompositionsQuery(), false);
            SubmitOperation so = null;

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

                SelfReferencingComposition parent = ctxt.SelfReferencingCompositions.Single(p => p.ID == 5);
                Assert.IsNull(parent.Child);
                parent.Value += "x";

                so = ctxt.SubmitChanges(TestHelperMethods.DefaultOperationAction, null);
            });
            EnqueueConditional(() => so.IsComplete);
            EnqueueCallback(delegate
            {
                Assert.IsFalse(so.HasError);
            });

            EnqueueTestComplete();
        }