Пример #1
0
        public void TestDeleteFlagsSetContactPerson()
        {
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();

            Assert.IsTrue(myContact.Status.IsNew); // this object is new
            myContact.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            myContact.SetPropertyValue("FirstName", "Brad");
            myContact.SetPropertyValue("Surname", "Vincent");
            myContact.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            myContact.SetPropertyValue("PK1Prop2", Guid.NewGuid());

            myContact.Save();                       //save the object to the DB
            Assert.IsFalse(myContact.Status.IsNew); // this object is saved and thus no longer
            // new
            Assert.IsFalse(myContact.Status.IsDeleted);

            IPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database

            Assert.AreEqual(id, myContact.ID);
            myContact.MarkForDelete();
            Assert.IsTrue(myContact.Status.IsDeleted);
            myContact.Save();
            Assert.IsTrue(myContact.Status.IsDeleted);
            Assert.IsTrue(myContact.Status.IsNew);
        }
Пример #2
0
 private void CreateSaveContactPersonTestPack()
 {
     mContactPTestSave = new ContactPersonCompositeKey();
     mContactPTestSave.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
     mContactPTestSave.SetPropertyValue("FirstName", "Brad");
     mContactPTestSave.SetPropertyValue("Surname", "Vincent");
     mContactPTestSave.SetPropertyValue("PK1Prop1", Guid.NewGuid());
     mContactPTestSave.SetPropertyValue("PK1Prop2", Guid.NewGuid());
     mContactPTestSave.Save(); //save the object to the DB
 }
Пример #3
0
 private void CreateSaveContactPersonTestPack()
 {
     mContactPTestSave = new ContactPersonCompositeKey();
     mContactPTestSave.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
     mContactPTestSave.SetPropertyValue("FirstName", "Brad");
     mContactPTestSave.SetPropertyValue("Surname", "Vincent");
     mContactPTestSave.SetPropertyValue("PK1Prop1", Guid.NewGuid());
     mContactPTestSave.SetPropertyValue("PK1Prop2", Guid.NewGuid());
     mContactPTestSave.Save(); //save the object to the DB
 }
Пример #4
0
        private void CreateUpdatedContactPersonTestPack()
        {
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();

            myContact.SetPropertyValue("DateOfBirth", new DateTime(1969, 01, 29));
            myContact.SetPropertyValue("FirstName", "FirstName");
            myContact.SetPropertyValue("Surname", "Surname");
            myContact.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            myContact.SetPropertyValue("PK1Prop2", Guid.NewGuid());
            myContact.Save();
            updateContactPersonID = myContact.ID;
        }
Пример #5
0
        private void CreateDeletedPersonTestPack()
        {
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();
            myContact.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            myContact.SetPropertyValue("FirstName", "Brad");
            myContact.SetPropertyValue("Surname", "Vincent");
            myContact.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            myContact.SetPropertyValue("PK1Prop2", Guid.NewGuid());
            myContact.Save(); //save the object to the DB
            myContact.MarkForDelete();
            myContact.Save();

            mContactPDeleted = myContact;
        }
Пример #6
0
        private void CreateDeletedPersonTestPack()
        {
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();

            myContact.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            myContact.SetPropertyValue("FirstName", "Brad");
            myContact.SetPropertyValue("Surname", "Vincent");
            myContact.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            myContact.SetPropertyValue("PK1Prop2", Guid.NewGuid());
            myContact.Save(); //save the object to the DB
            myContact.MarkForDelete();
            myContact.Save();

            mContactPDeleted = myContact;
        }
Пример #7
0
        public void RecoverNewObjectFromObjectManagerBeforeAndAfterPersist()
        {
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();

            myContact.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            myContact.SetPropertyValue("FirstName", "Brad");
            myContact.SetPropertyValue("Surname", "Vincent");
            myContact.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            myContact.SetPropertyValue("PK1Prop2", Guid.NewGuid());
            IPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database

            myContact.Save();              //save the object to the DB

            //			BOPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database
            Assert.AreEqual(id, myContact.ID);

            ContactPersonCompositeKey mySecondContactPerson = ContactPersonCompositeKey.GetContactPersonCompositeKey(id);

            Assert.IsTrue(ReferenceEquals(myContact, mySecondContactPerson));
            Assert.AreEqual(myContact.ID,
                            mySecondContactPerson.ID);
            Assert.AreEqual(myContact.GetPropertyValue("FirstName"), mySecondContactPerson.GetPropertyValue("FirstName"));
            Assert.AreEqual(myContact.GetPropertyValue("DateOfBirth"),
                            mySecondContactPerson.GetPropertyValue("DateOfBirth"));

            //Change the MyContact's Surname see if mySecondContactPerson is changed.
            //this should change since the second contact person was obtained from object manager and
            // these should thus be the same instance.
            myContact.SetPropertyValue("Surname", "New Surname");
            Assert.AreEqual(myContact.GetPropertyValue("Surname"), mySecondContactPerson.GetPropertyValue("Surname"));
        }
Пример #8
0
        public void SaveNewObjectWithDuplicatePrimaryKey()
        {
            //---------------Set up test pack-------------------
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();

            myContact.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            myContact.SetPropertyValue("FirstName", "Brad");
            myContact.SetPropertyValue("Surname", "Vincent");
            myContact.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            myContact.SetPropertyValue("PK1Prop2", Guid.NewGuid());
            IPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database

            myContact.Save();              //save the object to the DB
            FixtureEnvironment.ClearBusinessObjectManager();
            //			BOPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database
            Assert.AreEqual(id, myContact.ID);

            ContactPersonCompositeKey mySecondContactPerson =
                new ContactPersonCompositeKey();

            mySecondContactPerson.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            mySecondContactPerson.SetPropertyValue("FirstName", "Brad");
            mySecondContactPerson.SetPropertyValue("Surname", "Vincent");
            mySecondContactPerson.SetPropertyValue("PK1Prop1", myContact.GetPropertyValue("PK1Prop1"));
            mySecondContactPerson.SetPropertyValue("PK1Prop2", myContact.GetPropertyValue("PK1Prop2"));

            //---------------Execute Test ----------------------
            try
            {
                mySecondContactPerson.Save();
                Assert.Fail("Expected to throw an BusObjDuplicateConcurrencyControlException");
            }
            //---------------Test Result -----------------------
            catch (BusObjDuplicateConcurrencyControlException ex)
            {
                StringAssert.Contains("A 'Contact Person Composite Key' already exists with the same identifier", ex.Message);
            }
        }
Пример #9
0
        public void ChangeObjectPrimaryKeyAndThenCreateNewObjectWithPreviousPrimaryKey()
        {
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();

            myContact.SetPropertyValue("Surname", "Vincent");
            Guid prop_1_ID = Guid.NewGuid();
            Guid prop_2_ID = Guid.NewGuid();

            myContact.SetPropertyValue("PK1Prop1", prop_1_ID.ToString());
            myContact.SetPropertyValue("PK1Prop2", prop_2_ID.ToString());
            myContact.Save();
            //modify the primary key
            myContact.SetPropertyValue("PK1Prop1", prop_1_ID + "1");
            myContact.SetPropertyValue("PK1Prop1", prop_1_ID + "1");
            myContact.Save();

            ContactPersonCompositeKey myContactTwo = new ContactPersonCompositeKey();

            myContactTwo.SetPropertyValue("Surname", "Vincent 2");
            myContactTwo.SetPropertyValue("PK1Prop1", prop_1_ID.ToString());
            myContactTwo.SetPropertyValue("PK1Prop2", prop_2_ID.ToString());
            myContactTwo.Save();
        }
Пример #10
0
        public void TestUpdateExistingContactPerson()
        {
            ContactPersonCompositeKey myContactPerson =
                ContactPersonCompositeKey.GetContactPersonCompositeKey(updateContactPersonID);

            myContactPerson.SetPropertyValue("FirstName", "NewFirstName");
            myContactPerson.Save();

            ContactPersonCompositeKey.ClearContactPersonCol();
            //Reload the person and make sure that the changes have been made.
            ContactPersonCompositeKey myNewContactPerson =
                ContactPersonCompositeKey.GetContactPersonCompositeKey(updateContactPersonID);

            Assert.AreEqual("NewFirstName", myNewContactPerson.GetPropertyValue("FirstName"),
                            "The firstName was not updated");
        }
Пример #11
0
        public void TestSaveContactPerson()
        {
            //-----------------------------Setup Test Pack-----------------------------
            ContactPersonCompositeKey contactPTestSave = new ContactPersonCompositeKey();

            contactPTestSave.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            contactPTestSave.SetPropertyValue("FirstName", "Brad");
            contactPTestSave.SetPropertyValue("Surname", "Vincent");
            contactPTestSave.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            contactPTestSave.SetPropertyValue("PK1Prop2", Guid.NewGuid());
            contactPTestSave.Save(); //save the object to the DB


            FixtureEnvironment.ClearBusinessObjectManager();
            WaitForGC();

            //---------------------------Assert Precondition --------------------------
            Assert.IsFalse(contactPTestSave.Status.IsNew); // this object is saved and thus no longer
            // new

            IPrimaryKey id = contactPTestSave.ID; //Save the objectsID so that it can be loaded from the Database

            Assert.AreEqual(id, contactPTestSave.ID);

            //--------------------------Execute ---------------------------------------
            ContactPersonCompositeKey secondContactPerson = ContactPersonCompositeKey.GetContactPersonCompositeKey(id);

            //-------------------------Assert Result ----------------------------------
            Assert.AreNotSame(contactPTestSave, secondContactPerson);

            Assert.IsFalse(secondContactPerson.Status.IsNew); // this object is recovered from the DB
            // and is thus not new.
//            Assert.AreEqual(contactPTestSave.ID.ToString().ToUpper(), secondContactPerson.ID.ToString());
            Assert.AreEqual(contactPTestSave.GetPropertyValue("FirstName"),
                            secondContactPerson.GetPropertyValue("FirstName"));
            Assert.AreEqual(contactPTestSave.GetPropertyValue("DateOfBirth"),
                            secondContactPerson.GetPropertyValue("DateOfBirth"));

            //For some reason doing this here old tests
            contactPTestSave.SetPropertyValue("FirstName", "Change FirstName");
            Assert.IsFalse(contactPTestSave.GetPropertyValue("FirstName") ==
                           secondContactPerson.GetPropertyValue("FirstName"));
        }
Пример #12
0
        public void ChangeObjectPrimaryKeyAndThenCreateNewObjectWithPreviousPrimaryKey()
        {
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();
            myContact.SetPropertyValue("Surname", "Vincent");
            Guid prop_1_ID = Guid.NewGuid();
            Guid prop_2_ID = Guid.NewGuid();
            myContact.SetPropertyValue("PK1Prop1", prop_1_ID.ToString());
            myContact.SetPropertyValue("PK1Prop2", prop_2_ID.ToString());
            myContact.Save();
            //modify the primary key
            myContact.SetPropertyValue("PK1Prop1", prop_1_ID + "1");
            myContact.SetPropertyValue("PK1Prop1", prop_1_ID + "1");
            myContact.Save();

            ContactPersonCompositeKey myContactTwo = new ContactPersonCompositeKey();
            myContactTwo.SetPropertyValue("Surname", "Vincent 2");
            myContactTwo.SetPropertyValue("PK1Prop1", prop_1_ID.ToString());
            myContactTwo.SetPropertyValue("PK1Prop2", prop_2_ID.ToString());
            myContactTwo.Save();
        }
Пример #13
0
        public void SaveNewObjectWithDuplicatePrimaryKey()
        {
            //---------------Set up test pack-------------------
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();
            myContact.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            myContact.SetPropertyValue("FirstName", "Brad");
            myContact.SetPropertyValue("Surname", "Vincent");
            myContact.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            myContact.SetPropertyValue("PK1Prop2", Guid.NewGuid());
            IPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database
            myContact.Save(); //save the object to the DB
            FixtureEnvironment.ClearBusinessObjectManager();
            //			BOPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database
            Assert.AreEqual(id, myContact.ID);

            ContactPersonCompositeKey mySecondContactPerson =
                new ContactPersonCompositeKey();
            mySecondContactPerson.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            mySecondContactPerson.SetPropertyValue("FirstName", "Brad");
            mySecondContactPerson.SetPropertyValue("Surname", "Vincent");
            mySecondContactPerson.SetPropertyValue("PK1Prop1", myContact.GetPropertyValue("PK1Prop1"));
            mySecondContactPerson.SetPropertyValue("PK1Prop2", myContact.GetPropertyValue("PK1Prop2"));

            //---------------Execute Test ----------------------
            try
            {
                mySecondContactPerson.Save();
                Assert.Fail("Expected to throw an BusObjDuplicateConcurrencyControlException");
            }
                //---------------Test Result -----------------------
            catch (BusObjDuplicateConcurrencyControlException ex)
            {
                StringAssert.Contains("A 'Contact Person Composite Key' already exists with the same identifier", ex.Message);
            }
        }
Пример #14
0
        public void TestDeleteFlagsSetContactPerson()
        {
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();
            Assert.IsTrue(myContact.Status.IsNew); // this object is new
            myContact.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            myContact.SetPropertyValue("FirstName", "Brad");
            myContact.SetPropertyValue("Surname", "Vincent");
            myContact.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            myContact.SetPropertyValue("PK1Prop2", Guid.NewGuid());

            myContact.Save(); //save the object to the DB
            Assert.IsFalse(myContact.Status.IsNew); // this object is saved and thus no longer
            // new
            Assert.IsFalse(myContact.Status.IsDeleted);

            IPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database
            Assert.AreEqual(id, myContact.ID);
            myContact.MarkForDelete();
            Assert.IsTrue(myContact.Status.IsDeleted);
            myContact.Save();
            Assert.IsTrue(myContact.Status.IsDeleted);
            Assert.IsTrue(myContact.Status.IsNew);
        }
Пример #15
0
        public void TestSaveContactPerson()
        {
            //-----------------------------Setup Test Pack-----------------------------
            ContactPersonCompositeKey contactPTestSave = new ContactPersonCompositeKey();
            contactPTestSave.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            contactPTestSave.SetPropertyValue("FirstName", "Brad");
            contactPTestSave.SetPropertyValue("Surname", "Vincent");
            contactPTestSave.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            contactPTestSave.SetPropertyValue("PK1Prop2", Guid.NewGuid());
            contactPTestSave.Save(); //save the object to the DB


            FixtureEnvironment.ClearBusinessObjectManager();
            WaitForGC();

            //---------------------------Assert Precondition --------------------------
            Assert.IsFalse(contactPTestSave.Status.IsNew); // this object is saved and thus no longer
            // new

            IPrimaryKey id = contactPTestSave.ID; //Save the objectsID so that it can be loaded from the Database
            Assert.AreEqual(id, contactPTestSave.ID);

            //--------------------------Execute ---------------------------------------
            ContactPersonCompositeKey secondContactPerson = ContactPersonCompositeKey.GetContactPersonCompositeKey(id);

            //-------------------------Assert Result ----------------------------------
            Assert.AreNotSame(contactPTestSave, secondContactPerson);

            Assert.IsFalse(secondContactPerson.Status.IsNew); // this object is recovered from the DB
            // and is thus not new.
//            Assert.AreEqual(contactPTestSave.ID.ToString().ToUpper(), secondContactPerson.ID.ToString());
            Assert.AreEqual(contactPTestSave.GetPropertyValue("FirstName"),
                            secondContactPerson.GetPropertyValue("FirstName"));
            Assert.AreEqual(contactPTestSave.GetPropertyValue("DateOfBirth"),
                            secondContactPerson.GetPropertyValue("DateOfBirth"));

            //For some reason doing this here old tests
            contactPTestSave.SetPropertyValue("FirstName", "Change FirstName");
            Assert.IsFalse(contactPTestSave.GetPropertyValue("FirstName") ==
                           secondContactPerson.GetPropertyValue("FirstName"));
        }
Пример #16
0
 private void CreateUpdatedContactPersonTestPack()
 {
     ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();
     myContact.SetPropertyValue("DateOfBirth", new DateTime(1969, 01, 29));
     myContact.SetPropertyValue("FirstName", "FirstName");
     myContact.SetPropertyValue("Surname", "Surname");
     myContact.SetPropertyValue("PK1Prop1", Guid.NewGuid());
     myContact.SetPropertyValue("PK1Prop2", Guid.NewGuid());
     myContact.Save();
     updateContactPersonID = myContact.ID;
 }
Пример #17
0
        public void RecoverNewObjectFromObjectManagerBeforeAndAfterPersist()
        {
            ContactPersonCompositeKey myContact = new ContactPersonCompositeKey();
            myContact.SetPropertyValue("DateOfBirth", new DateTime(1980, 01, 22));
            myContact.SetPropertyValue("FirstName", "Brad");
            myContact.SetPropertyValue("Surname", "Vincent");
            myContact.SetPropertyValue("PK1Prop1", Guid.NewGuid());
            myContact.SetPropertyValue("PK1Prop2", Guid.NewGuid());
            IPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database
            myContact.Save(); //save the object to the DB

            //			BOPrimaryKey id = myContact.ID; //Save the objectsID so that it can be loaded from the Database
            Assert.AreEqual(id, myContact.ID);

            ContactPersonCompositeKey mySecondContactPerson = ContactPersonCompositeKey.GetContactPersonCompositeKey(id);

            Assert.IsTrue(ReferenceEquals(myContact, mySecondContactPerson));
            Assert.AreEqual(myContact.ID,
                            mySecondContactPerson.ID);
            Assert.AreEqual(myContact.GetPropertyValue("FirstName"), mySecondContactPerson.GetPropertyValue("FirstName"));
            Assert.AreEqual(myContact.GetPropertyValue("DateOfBirth"),
                            mySecondContactPerson.GetPropertyValue("DateOfBirth"));

            //Change the MyContact's Surname see if mySecondContactPerson is changed.
            //this should change since the second contact person was obtained from object manager and 
            // these should thus be the same instance.
            myContact.SetPropertyValue("Surname", "New Surname");
            Assert.AreEqual(myContact.GetPropertyValue("Surname"), mySecondContactPerson.GetPropertyValue("Surname"));
        }