コード例 #1
0
        public void Association_Inheritance_Modify_Singleton_Derived_Association()
        {
            AssociationInheritanceScenarios ctxt = new AssociationInheritanceScenarios(AssociationInheritanceScenarios_Uri);

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

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

                AI_MasterDerived master = ctxt.AI_Masters.OfType<AI_MasterDerived>().FirstOrDefault();
                Assert.IsNotNull(master, "expected one master");

                AI_DetailDerived3 d3 = master.DetailDerived3;
                Assert.IsNotNull(d3, "no master.D3");
                Assert.AreSame(master, d3.Master, "wrong master.D3");

                // Verify we can unset it
                master.DetailDerived3 = null;
                Assert.IsNull(master.DetailDerived3, "could not reset master.D4");

                AI_DetailDerived3 newD3 = new AI_DetailDerived3();
                newD3.ID = 99;
                master.DetailDerived3 = newD3;

                AI_DetailDerived4 newD4 = new AI_DetailDerived4();
                newD4.ID = 999;
                master.DetailDerived4 = newD4;

                so = ctxt.SubmitChanges();
            });

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

            EnqueueTestComplete();
        }
コード例 #2
0
        public void Association_Inheritance_Modify_MultipleValue_Derived_Association()
        {
            AssociationInheritanceScenarios ctxt = new AssociationInheritanceScenarios(AssociationInheritanceScenarios_Uri);

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

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

                AI_MasterDerived master = ctxt.AI_Masters.OfType<AI_MasterDerived>().FirstOrDefault();
                Assert.IsNotNull(master, "expected 1 master");

                // Verify we can remove one derived from the list
                AI_DetailDerived1 d1 = master.DetailDerived1s.First();
                master.DetailDerived1s.Remove(d1);
                Assert.AreEqual(1, master.DetailDerived1s.Count, "master.D1s.Remove didn't work");

                AI_DetailDerived1 newD1 = new AI_DetailDerived1();
                newD1.ID = 9999;

                master.DetailDerived1s.Add(newD1);
                Assert.AreEqual(2, master.DetailDerived1s.Count, "master.D1s.Add didn't work");

                AI_DetailDerived2 newD2 = new AI_DetailDerived2();
                newD2.ID = 99999;

                master.DetailDerived2s.Add(newD2);
                Assert.AreEqual(3, master.DetailDerived2s.Count, "master.D2s.Add didn't work");

                so = ctxt.SubmitChanges();
            });

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

            EnqueueTestComplete();
        }