예제 #1
0
        public void TestGetRelatedBusinessObjectCollection_SortOrder_ChangeOrder()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            ContactPersonTestBO.LoadClassDefWithAddressesRelationship_SortOrder_AddressLine1();
            ContactPersonTestBO cp       = ContactPersonTestBO.CreateSavedContactPersonNoAddresses();
            AddressTestBO       address1 = new AddressTestBO();

            address1.ContactPersonID = cp.ContactPersonID;
            address1.AddressLine1    = "ffff";
            address1.Save();
            AddressTestBO address2 = new AddressTestBO();

            address2.ContactPersonID = cp.ContactPersonID;
            address2.AddressLine1    = "bbbb";
            address2.Save();

            //---------------Assert PreConditions---------------
            RelatedBusinessObjectCollection <AddressTestBO> addresses = cp.Addresses;

            Assert.AreEqual(2, addresses.Count);
            Assert.AreSame(address1, addresses[1]);
            Assert.AreSame(address2, addresses[0]);

            //---------------Execute Test ----------------------
            address2.AddressLine1 = "zzzzz";
            address2.Save();
            RelatedBusinessObjectCollection <AddressTestBO> addressesAfterChangeOrder = cp.Addresses;

            //---------------Test Result -----------------------

            Assert.AreSame(address1, addressesAfterChangeOrder[0]);
            Assert.AreSame(address2, addressesAfterChangeOrder[1]);
        }
예제 #2
0
        public void TestRemoveRelatedObject_AsBusinessObjectCollection()
        {
            //-----Create Test pack---------------------
            ClassDef.ClassDefs.Clear();
            ContactPersonTestBO.LoadClassDefWithAddressesRelationship_DeleteRelated();
            ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateSavedContactPersonNoAddresses();
            AddressTestBO       address             = contactPersonTestBO.Addresses.CreateBusinessObject();

            address.Save();
            //-------Assert Precondition ------------------------------------
            Assert.AreEqual(1, contactPersonTestBO.Addresses.Count);

            //-----Run tests----------------------------
            BusinessObjectCollection <AddressTestBO> addresses = contactPersonTestBO.Addresses;

            addresses.Remove(address);

            ////-----Test results-------------------------
            Assert.AreEqual(1, addresses.RemovedBusinessObjects.Count);
            Assert.AreEqual(0, addresses.Count);
            Assert.IsNull(address.ContactPersonID);
            Assert.IsNull(address.ContactPersonTestBO);
//            Assert.IsTrue(address.Status.IsDeleted);
            Assert.AreEqual(1, addresses.PersistedBusinessObjects.Count);
        }
        private ContactPersonTestBO CreateContactPersonWithAddress()
        {
            var cp1 = CreateContactPerson();
            var add = new AddressTestBO();

            add.ContactPersonTestBO = cp1;
            add.Save();
            return(cp1);
        }
예제 #4
0
        public void TestRemoveRelatedObject_SetsRemovedBO()
        {
            //-----Create Test pack---------------------
            ClassDef.ClassDefs.Clear();
            ContactPersonTestBO.LoadClassDefWithAddressesRelationship_DeleteRelated();
            ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateSavedContactPersonNoAddresses();
            RelatedBusinessObjectCollection <AddressTestBO> addresses1 = contactPersonTestBO.Addresses;
            AddressTestBO address = addresses1.CreateBusinessObject();

            address.Save();

            //-----Run tests----------------------------
            RelatedBusinessObjectCollection <AddressTestBO> addresses = addresses1;

            addresses.Remove(address);

            ////-----Test results-------------------------
            Assert.AreSame(contactPersonTestBO, address.Relationships.GetSingle <ContactPersonTestBO>("ContactPersonTestBO").RemovedBO);
        }
 private ContactPersonTestBO CreateContactPersonWithAddress()
 {
     var cp1 = CreateContactPerson();
     var add = new AddressTestBO();
     add.ContactPersonTestBO = cp1;
     add.Save();
     return cp1;
 }
예제 #6
0
        public void TestGetRelatedBusinessObjectCollection_SortOrder_ChangeOrder()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            ContactPersonTestBO.LoadClassDefWithAddressesRelationship_SortOrder_AddressLine1();
            ContactPersonTestBO cp = ContactPersonTestBO.CreateSavedContactPersonNoAddresses();
            AddressTestBO address1 = new AddressTestBO();
            address1.ContactPersonID = cp.ContactPersonID;
            address1.AddressLine1 = "ffff";
            address1.Save();
            AddressTestBO address2 = new AddressTestBO();
            address2.ContactPersonID = cp.ContactPersonID;
            address2.AddressLine1 = "bbbb";
            address2.Save();

            //---------------Assert PreConditions---------------     
            RelatedBusinessObjectCollection<AddressTestBO> addresses = cp.Addresses;
            Assert.AreEqual(2, addresses.Count);
            Assert.AreSame(address1, addresses[1]);
            Assert.AreSame(address2, addresses[0]);

            //---------------Execute Test ----------------------
            address2.AddressLine1 = "zzzzz";
            address2.Save();
            RelatedBusinessObjectCollection<AddressTestBO> addressesAfterChangeOrder = cp.Addresses;

            //---------------Test Result -----------------------

            Assert.AreSame(address1, addressesAfterChangeOrder[0]);
            Assert.AreSame(address2, addressesAfterChangeOrder[1]);
        }